BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Oluwole
Fluorite | Level 6

I recreated a one to one match using the PROC SURVEYSELECT. I have the final match dataset with only 4 variables inclduing matchID in the dataset.

How do I relate this to the original dataset from where the cases and control were selected so I can work on the matched data?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

You need to merge/join the two datasets in to the SurveySelect output. 

 

You'll need to rename the variables so you can identify the match/control records. This assumes you have different datasets with your control and match data. 

 

Proc sql;

Create table matched as 

Select a.* /*first set of records Control dataset*/
B.id as match_id, b.name as match_name, .... etc, /* Match dataset, rename variables because variables cannot have the same name*/
Ss.index /*Include the variable index from the SurveySelect data*/

From SurveySelect as ss /*Match/Control dataset shown*/

Left join control as a /*Get information from control dataset, match on ID*/
On ss.control_id = a.id

Left join match as b  /*Merge information from the match dataset, match on ID*/
On ss.match_id = b.id;

Quit;

View solution in original post

5 REPLIES 5
art297
Opal | Level 21

Would help if you provide example have and want datasets in the form of data step code.

 

Art, CEO, AnalystFinder.com

 

Oluwole
Fluorite | Level 6
 
Oluwole
Fluorite | Level 6

I will appreciate the dataset code,

Thanks.

Reeza
Super User

You need to merge/join the two datasets in to the SurveySelect output. 

 

You'll need to rename the variables so you can identify the match/control records. This assumes you have different datasets with your control and match data. 

 

Proc sql;

Create table matched as 

Select a.* /*first set of records Control dataset*/
B.id as match_id, b.name as match_name, .... etc, /* Match dataset, rename variables because variables cannot have the same name*/
Ss.index /*Include the variable index from the SurveySelect data*/

From SurveySelect as ss /*Match/Control dataset shown*/

Left join control as a /*Get information from control dataset, match on ID*/
On ss.control_id = a.id

Left join match as b  /*Merge information from the match dataset, match on ID*/
On ss.match_id = b.id;

Quit;
ballardw
Super User

For future use you can use the option OUTALL on the Proc Surveyselect statement. This will add a variable SELECTED to the output set that will have a 1 for the selected records and 0 for the non-selected.

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!

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
  • 5 replies
  • 1149 views
  • 2 likes
  • 4 in conversation