i have a stored process which gets id's
it looks like 17,18,19 for example
now what i want to do here is to append them all to the same dataset but with different variable names (A_17, A_18 , B_17, B_18 )
but at this point it already fails to read my do while statement
any help?
%macro CreateGraphData;
%let i = 0;
%do %while (scan(&curve_id,&i,',') NE '');
current_id = scan(&curve_id,&i,',');
data wacom_&i;
set RF300l3.wacom_main;
where curve_id = current_id;
run;
data wacom_&i (drop = A B);
set RF300l3.wacom_data;
where curve_id = current_id;
A_&i = A;
B_&i = B;
run;
if &i = 1 then do;
data all_data;
set wacom_&i;
run;
end;
else do;
proc append base=all_data data=wacom_&i force;run;
end;
%let i = &i + 1;
%end;
%mend;
%CreateGraphData;
ok, i almost there
%macro GraphsData;
%let num=1;
%let Curve=%scan(&curve_id,&num,'#');
%do %while(&Curve ne);
%put 1: &Curve;
/* do action for this curve */
data wacom_#
set RF300l3.wacom_main;
where curve_id = &Curve;
run;
data wacom_#
set RF300l3.wacom_data;
where curve_id = &Curve;
run;
/*
if &i = 1 then do;
data all_data;
set wacom_&i;
run;
end;
else do;
proc append base=all_data data=wacom_&i force;run;
end;
*/
/* scan for next round */
%let num=%eval(&num+1);
%let Curve=%scan(&curve_id,&num,'#');
%end;
%mend;
%GraphsData;
you may not have noticed from examples that the macro language does not use quotes to indicate strings, but uses the %STR() function
So, not '#' but %STR(#) might help your %while()
This problem has been solved ?
Can you give an example ?
This isn´t hard, I just don´t get what you need.
Kassim
Do you need the intermediate datasets with the numeric suffix?
If not then why not just use a data step? Why do you need a macro?
data all_data;
set RF300l3.wacom_main;
where curve_id in (&Curve_id);
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.