BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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;
8 REPLIES 8
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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
PatrickG
SAS Employee
My guess is that it doesn't like the semicolons in your proc statement. Try using the quoting functions.
abdullala
Calcite | Level 5
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.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
abdullala
Calcite | Level 5
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!
SUN59338
Obsidian | Level 7
may have problem with statement of
put(status,8.0)

try put(status,8.)

you need one more semicolon after the quit

%else quit;;
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
Cynthia_sas
SAS Super FREQ
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

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 1684 views
  • 0 likes
  • 6 in conversation