a week ago
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!
a week ago
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?
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.
a week ago
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.