SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Astounding
PROC Star

OK, a brand new program and a brand new approach:

 

proc sort data=dataset1;
   by gender ageclass;
run;

proc sort data=dataset2;
   by gender ageclass;
run;

data dataset1_revised;
   set dataset1;
   drop subset;
   rename code = assigned_code;
   output;
   output;
run;

data want;
   in1=0;
   in2=0;
   merge dataset1_revised (in=in1)  dataset2 (in=in2);
   by gender ageclass;
   if in2;
   if in1=0 then assigned_code = ' ';
run;

Doing a many-to-many merge on purpose, after expanding DATASET1 so it has double the number of observations.

Patrick
Opal | Level 21

Nice!

I couldn't figure out how to determine in a many:many scenario if a row from a source table gets just repeated or if a new row gets read. Now you've showed me how that's done 🙂

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 16 replies
  • 3598 views
  • 6 likes
  • 8 in conversation