BookmarkSubscribeRSS Feed
Mystik
Obsidian | Level 7

Hello.

I have a SAS file called Prg_grp. One of the variables in this file is called "outcomes" coded as 0,1,2 or 3. 

1 in the outcome denotes = asthin

2 =  Coap

3 = Soca

However any of my outcome that is not either of the above is denoted = 0.

I have 11, 829,526 of observations but my total number based on ID without duplications is 85,000.

 

My file has other variables such as ID, medic, medic_date.

I want to remove duplicates so that only an ID has either 1, 2, or 3 and the total number of rows corresponding to my ID is exactly 85,000.

 

2 REPLIES 2
SuryaKiran
Meteorite | Level 14

Hi,

 

Why not an IF condition to only keep the records you need.

 

data want;
set have;
if outcomes in (1,2,3);
run;
Thanks,
Suryakiran
Mystik
Obsidian | Level 7

Thank you.

however, i will still get duplicates because, those codes in medic variable which are not 1, 2, 3 will still be available in medic variable. So those observations will still be present in medic.

Running a proc freq on outcome variable will yield those values not coded 1,2 or 3 as missing.

Also the outcome variables of 1, 2 or 3 are based on a single code in medic or combination of codes.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 978 views
  • 0 likes
  • 2 in conversation