BookmarkSubscribeRSS Feed
robertrao
Quartz | Level 8

When I do this step i am not getting a and b merged instead the info available in other dataset also appears . Likewise with c and d  and e and f also..........!!!!Can somebody help me?

Thanks

data LOS_final_1 MORT_final_1 READMITS_final_1;

mergeLOS_ranks(in=a) LOS_Percentiles(in=b)

MORT_ranks(in=c) MORT_Percentiles(in=d)

READMITS_ranks(in=e) READMITS_Percentiles(in=f);

byDischarge_Quarter;

if a and b then output LOS_final_1;

if c and d then output MORT_final_1;

if e and f then output READMITS_final_1;

run;

6 REPLIES 6
ballardw
Super User

You will need to add either a KEEP= or DROP= option to the output data sets to get the variables you want. The choice would depend on which creates a longer list. It might look something like this

data LOS_final_1 ( keep = Discharge_Quarter var1 var2)

     MORT_final_1 ( drop = var5-var15)

     READMITS_final_1 (keep = list of variable names you want);


robertrao
Quartz | Level 8

The variablke names are different for each of these datasets except for only 2 variable names which are common to all the rank datasets.

the variable names for the percentiles dataset are different.

BASICALLY I DINT WANT TO DO THIS STEP:

data
LOS_final_1;

merge LOS_ranks(in=a) LOS_Percentiles(in=b);

by Discharge_Quarter;

run;

data MORT_final_1;

merge MORT_ranks(in=a) MORT_Percentiles(in=b);

by
Discharge_Quarter;

run;

data READMITS_final_1;

merge READMITS_ranks(in=a) READMITS_Percentiles(in=b);

by Discharge_Quarter;

run;

Reeza
Super User

Then you need to rename your variables because if you merge with the same variable names they will overwrite each other.

Astounding
PROC Star

Why would you not use 3 DATA steps, each with its own MERGE?  That program does exactly what you need.  What is the reason for trying to switch?

robertrao
Quartz | Level 8

Thats a good question. That works perfectly fine. But since i am a beginner in using sas programming i am trying to learn all the possible ways.

Astounding
PROC Star

Then this illustrates a good lesson.  While there are often many ways to achieve an acceptable solution in SAS, pick the right tool for the job.  If you do, your program will usually be short and simple.  If you pick the wrong tool for the job, your program will become complex and more difficult to work with.  Occasionally, a programming objective requires complexity.  (Unfortunately, if you hang out here you see a non-representative sample of more complex problems, not the simple ones.)  As a general rule, if your program is become complex, think about whether there is another way to get what you want.

Good luck.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 1397 views
  • 0 likes
  • 4 in conversation