BookmarkSubscribeRSS Feed
Kiko
Fluorite | Level 6

Hello, 

 

I have two datasets called A and  B- group B is a subset of group A (everyone in group B should be in group A), and group B is the people who had an event/outcome, and ultimately I'd like to have a master dataset w. people who had an event and who had not had an event. Then I would like to have a new variable (e.g. outcome) and assign values so that everyone from B should have 1 and the rest of the people have 0. What SAS procedures should I use? Any suggestion/examples would be greatly appreciated. 

 

Thank you.

 

 

 

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

This is pretty straighforward if you provide some sample data 🙂

Reeza
Super User

This is data management, combing datasets, which is handled either in a data step or proc SQL. 

 

Data want;

set A B indsname=source;

 

source_dsn = source;

 

run;

 

Relevant reference, there's many examples here:

http://support.sas.com/documentation/cdl/en/basess/68381/HTML/default/viewer.htm#p19t3r1gxavpoin14jd...

andreas_lds
Jade | Level 19

Similar questions are asked at least daily, please use the search functionality.

 

New documentation site: http://documentation.sas.com/?cdcId=pgmmvacdc&cdcVersion=9.4&docsetId=basewn&docsetTarget=helpcenter...

 

Related to your problem: http://documentation.sas.com/?cdcId=pgmmvacdc&cdcVersion=9.4&docsetId=basess&docsetTarget=p19t3r1gxa...

Astounding
PROC Star

If B is a subset of A, you could use this approach:

 

proc sort data=a;

by id;

run;

 

proc sort data=b;

by id;

run;

 

data want;

merge a b (in=b);

by id;

outcome=b;

run;

 

You haven't told us the names of your variables, so I'm using ID here as the common variable to match on.

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
  • 880 views
  • 0 likes
  • 5 in conversation