Hi SAS Users,
I am having multiple SAS datasets in the below mentioned paths.
libname base "C:/SASUniversityEdition/myfolders/sasuser.v94/base"; /*(e.g. have_base, adverse_base, conmeds_base)*/
libname current "C:/SASUniversityEdition/myfolders/sasuser.v94/current"; /*(e.g. have_current, adverse_current,conmeds_current)*/
now we want to pickup all SAS datasets from the corresponding path and run it on the code.
lile it has to pick up have_base data from /base path and have_current data from /current path then run the code and generate the output in one dataset. AND
it has to pick up adverse_base data from /base path and adverse_current data from /current path then run the code and generate the output in one dataset.
finally all output datasets should be one final dataset.
/*data in have_base*/
data have_base;
input name $ value month $;
cards;
bala 402 jun
sri 593 sep
sudh 543 jul
;
run;
proc sort data=have_ base;
by name;
run;
/*data in have_current*/
data have_current;
input name $ value month $;
cards;
bal 432 jun
sri 543 sep
sudh 563 jul
;
run;
proc sort data=have_current;
by name;
run;
data both;
merge have_base(in=a) have_current(in=b);
by name;
if a and b;
run;
please do let me know if am not clear.
Kind Regards,
Raju
Please post working code that accomplishes what you want to turn into a macro.
Then identify the places that will be dynamic - ie change the data set names.
data both;
merge have_base(in=a) have_current(in=b);
by name;
if a and b;
run;
this is the working code.
now have_base and have_current datasets has to take from the paths which I have mentioned. then it has to check for other datasets (adverse_base and adverse_current) and so on....
Do you mean that have_base, adverse_base, conmeds_base,have_current, adverse_current,conmeds_current all end up in the same data set?
not exactly.
we have to pick datasets from the mentioned paths and it has to pass through the following code (first it should check for have_base and base_current then adverse_base and adverse_current and so on.... then finally all outputs should be in one dataset or if we have multiple outputs that is also fine).
data both;
merge have_base(in=a) have_current(in=b);
by name;
if a and b;
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.