Reputation: 13
I have created a macro to go over datasets and pull only variables I require. My issue is when macro switches from one variable to another, temp dataset is not appended to main dataset.
%macro runit;
%do a=1 %to %sysfunc(countw(&varlist,%str( )));
%let varlist_new=%scan(&varlist,&a);
Data work.new (Keep= studyid siteid CCVNAME VARIABLE) ;
set Input.&Dataset;
CCVNAME= "&Dataset";
VARIABLE= "&varlist_new";
run;
%end;
%mend runit;
%runit;
&Varlist value and &dataset values are coming from Metadata file.
I want work.new or a new proc SQL dataset to store all work.new coming out from the do loop.
Thank you in advance.
Upvotes: 0
Views: 150
Reputation: 51566
Because you did not include any code to append the temporary dataset into any permanent dataset. Why not just use PROC APPEND?
Generate the NEW dataset for each time through the loop. Then append the NEW dataset to the growing final dataset, let's call it ALL_OF_THEM.
%macro runit;
%local a varlist_new ;
%do a=1 %to %sysfunc(countw(&varlist,%str( )));
%let varlist_new=%scan(&varlist,&a,%str( ));
data work.new (Keep= studyid siteid CCVNAME VARIABLE) ;
set Input.&Dataset;
CCVNAME= "&Dataset";
VARIABLE= "&varlist_new";
run;
proc append base=all_of_them data=new force;
run;
%end;
%mend runit;
But I am not sure how that actually works since it seems to be copying the same data over and over and just calling it something different by changing the value of VARIABLE.
Upvotes: 1