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.¤t_node;
** when some condition is met;
select distinct trim(left(put(status,8.0))) into :class_label from project.¤t_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: ®list;
select distinct region into :reg1-:reg&cnt from shoes;
%put Now I have numbered macro vars: reg1=®1 reg2=®2 reg3=®3 reg4=®4;
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: ®list;
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=®1 reg2=®2 reg3=®3 reg4=®4;
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