BookmarkSubscribeRSS Feed
kari
Calcite | Level 5

Hello,

 

I am new to SAS and using weighted samples. 

 

Before I run my descriptives and analyses I need to merge two files and turn on weights. 

 

Specifically, I have one file that has my variables of interest and another that has my demographic variables. On top of that I have been instructed to merge two variables within each file to get individual scores. Does this make sense? 

 

IF so I am looking to determine the proper code to merge these files while also considering the need to merge these two variables with one another. - next step weighting!

3 REPLIES 3
ballardw
Super User

Providing some examples of what the files to merge currently look like and what the merged result should be is a good starting point to helping us help you.

 

One thing in 'merging' is how do you know which record in one file goes with which record in the other. Is there a variable (or 2 or 3 or ...) that uniquely identifies each record that is to be used to match the sets?

 


@kari wrote:

Hello,

 

On top of that I have been instructed to merge two variables within each file to get individual scores. Does this make sense? 


Not with out some sort of examples not much. This sounds somewhat like recoding which is using some rules to manipulate your data into a desired form. Such as setting a single category based on the values of two variables such as weight status might depend on gender, height and weight.

kari
Calcite | Level 5
Hello,


Thank you so much for the reply!


The first dataset contain most of my variables of interest and the second contains the demographic variables.


The two variables that must be merged to create a unique respondent are in both data files. One represents a household and one represents each individual per household. The idea is if I merge these two I have individual participants and then I must merge the two data sets to be able to run the analyses with all my variables. Please let me know if this makes sense. I appreciate your help!
ballardw
Super User

@kari wrote:
Hello,


Thank you so much for the reply!


The first dataset contain most of my variables of interest and the second contains the demographic variables.


The two variables that must be merged to create a unique respondent are in both data files. One represents a household and one represents each individual per household. The idea is if I merge these two I have individual participants and then I must merge the two data sets to be able to run the analyses with all my variables. Please let me know if this makes sense. I appreciate your help!

Show some examples similar to your data of the values that have to be combined. There might be issues if one of them is numeric and not character. This is not a difficult operation but some consideration as to length of variables being consistent, case of character values, John JOHN and john are not equal to computers. A relatively common approach is to concatenate two strings with another character such as _ so you can avoid some possible collisions. If you have one record with JOHN and SMITH and another with JOHNS and MITH without the _ the combined value would be the same. Basic code would look like:

NewId = catx('_',variable1,variable2);

but you should specify a length for the NewId variable before this using the longest expected length of variables 1 and 2 PLUS 1 for the underscore.

 

 

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 Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 820 views
  • 0 likes
  • 2 in conversation