BookmarkSubscribeRSS Feed
Raj_C
Obsidian | Level 7

 

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

4 REPLIES 4
Reeza
Super User

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.

 

 

Raj_C
Obsidian | Level 7

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....

ballardw
Super User

Do you mean that have_base, adverse_base, conmeds_base,have_current, adverse_current,conmeds_current all end up in the same data set?

 

Raj_C
Obsidian | Level 7

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 992 views
  • 1 like
  • 3 in conversation