DATA Step, Macro, Functions and more

can't figure out what that error is

Reply
N/A
Posts: 0

can't figure out what that error is

In the first line of the following coding, what the hell is wrong with error 180-322?

ERROR 180-322: Statement is not valid or it is used out of proper order.


%else %do; proc sql noprint; select count(distinct put(status,8.0)) into :status_count from project.&current_node; **************Check the singularity of status values for all partition datasets*****************;
%if %trim(%left(&status_count)) =1 %then %do;
select distinct trim(left(put(status,8.0))) into :class_label from project.&current_node; quit;
%put STATUS=&CLASS_LABEL;
%let index_none_tuple=%index(&update_node_list,&current_node);*********remove single class node from node list**********;
%let length_none_tuple=%length(&current_node);
%let update_node_list=%substr(&update_node_list, 1, %eval(&index_none_tuple-1))%substr(&update_node_list, %eval(&index_none_tuple+&length_none_tuple+1));

%end;
%else quit;

%end;
Super Contributor
Super Contributor
Posts: 3,174

Re: can't figure out what that error is

Posted in reply to deleted_user
You would benefit from running your code again with:

OPTIONS SOURCE SOURCE2 MGEN SGEN MLOGIC MPRINT;

Also, you didn't share the code that came just before the error -- my bet is you made some type of direct/indirect change to a SAS program and there is an open comment or some other syntax condition also that is occurring *BEFORE* this error.

Suggest some desk-checking before public forum rant keeps sanity in order.

Scott Barry
SBBWorks, Inc
SAS Employee
Posts: 58

Re: can't figure out what that error is

Posted in reply to deleted_user
My guess is that it doesn't like the semicolons in your proc statement. Try using the quoting functions.
Contributor
Posts: 74

Re: can't figure out what that error is

Posted in reply to deleted_user
seems that your code is from a macro. if so, any comment MUST be started with a %, e.g.

%******Check the singularity of status values for all partition datasets********;

very likely this is what your SAS is complaining about.
Super Contributor
Super Contributor
Posts: 3,174

Re: can't figure out what that error is

Posted in reply to abdullala
It's a bit late to the party guys - also, I have to disagree about the comment syntax - consider:

%macro x;
* I am a legitimate SAS comment. ;
%put Hello to the Digital Fjord. ;
%mend x;
%x;

Scott Barry
SBBWorks, Inc.
Contributor
Posts: 74

Re: can't figure out what that error is

well, i believe that although it may seem to have no harm in this simple code, it will bomb sooner or later ... it is always safe to precede the comment with a %, my hard-learned lesson!
Contributor
Posts: 24

Re: can't figure out what that error is

Posted in reply to deleted_user
may have problem with statement of
put(status,8.0)

try put(status,8.)

you need one more semicolon after the quit

%else quit;;
Super Contributor
Super Contributor
Posts: 3,174

Re: can't figure out what that error is

What has been revealed by the OP is an incomplete macro - we need to see the entire process, preferably as SAS is compiling and executing, if you really want to get a reasonable and credible response, without wasting others' time.

So, suggest you execute your SAS application program with the maximum SAS log diagnostics activated, including MACROGEN SYMBOLGEN and MLOGIC, then after reviewing the execution output yourself for desk-checking purpose/value, then re-post a reply to the forum and provide (COPY and PASTE) the SAS-generated SAS log output -- preferably all of it.

Scott Barry
SBBWorks, Inc.
SAS Super FREQ
Posts: 8,862

Re: can't figure out what that error is

Hi:
I agree with Scott...there is not enough information. For one thing, I'd like to see the WORKING SAS program that you started with. If, for example, we strip out ALL the macro code, we are reduced to this:

[pre]
proc sql noprint;
select count(distinct put(status,8.0)) into :status_count from project.&current_node;

** when some condition is met;
select distinct trim(left(put(status,8.0))) into :class_label from project.&current_node; quit;
** issue a bunch of %LET statements;
** end of second select distinct;
quit;
[/pre]

Do you expect to get a count in &status_count???? Is there only 1 status??? Did you want a list of all the distinct status values in one macro var or in multiple macro vars??

Consider the following example that uses 4 regions from SASHELP.SHOES:
[pre]
** make a file with 4 regions;
proc sort data=sashelp.shoes out=shoes;
where region in ('Asia', 'Canada', 'Pacific', 'Western Europe');
by region;
run;

** these are some different ways that I could write WORKING code;
proc sql;
select count(distinct region) into :cnt from shoes;
%let cnt = &cnt; /* strip leading and trailing blanks from CNT macro var */
%put number of regions in cnt is &cnt;

select distinct region into :reg from shoes;
%put There are 4 regions in the file, but I will only get: ®


select distinct region into :reglist separated by '~' from shoes ;
%put There are 4 regions and I get: &reglist;

select distinct region into :reg1-:reg&cnt from shoes;
%put Now I have numbered macro vars: reg1=&reg1 reg2=&reg2 reg3=&reg3 reg4=&reg4;

quit;
[/pre]

generates these results in the SAS log:
[pre]
160 ** make a file with 4 regions;
161 proc sort data=sashelp.shoes out=shoes;
162 where region in ('Asia', 'Canada', 'Pacific', 'Western Europe');
163 by region;
164 run;

NOTE: There were 158 observations read from the data set SASHELP.SHOES.
WHERE region in ('Asia', 'Canada', 'Pacific', 'Western Europe');
NOTE: The data set WORK.SHOES has 158 observations and 7 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds


165
166 ** these are some different ways that I could write WORKING code;
167 proc sql;
168 select count(distinct region) into :cnt from shoes;
169 %let cnt = &cnt; /* strip leading and trailing blanks from CNT macro var */
170 %put number of regions in cnt is &cnt;
number of regions in cnt is 4
171
172 select distinct region into :reg from shoes;
173 %put There are 4 regions in the file, but I will only get: ®
There are 4 regions in the file, but I will only get: Asia
174
175
176 select distinct region into :reglist separated by '~' from shoes ;
177 %put There are 4 regions and I get: &reglist;
There are 4 regions and I get: Asia~Canada~Pacific~Western Europe
178
179 select distinct region into :reg1-:reg&cnt from shoes;
180 %put Now I have numbered macro vars: reg1=&reg1 reg2=&reg2 reg3=&reg3 reg4=&reg4;
Now I have numbered macro vars: reg1=Asia reg2=Canada reg3=Pacific reg4=Western Europe
181
182 quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

[/pre]

What is your WORKING code that you started with? What does your data look like (or a subset of your data)? What do you expect to see and then what is the resolved code that you expect your macro program to generate??

cynthia
Ask a Question
Discussion stats
  • 8 replies
  • 253 views
  • 0 likes
  • 6 in conversation