Below is a homework question with some data. I have done pieces of this that work well (rename, merge, catx) but when I try to run multiple pieces of it together, it never comes out looking quite right. I have never merged two data sets together before, so I'm hoping someone can show me how it's done on this problem.
The temporary SAS data sets ‘StJohns’ and ‘CM’ below show data sets containing the same information. However, this information was collected differently at each site (different variable names, variable values, etc.). SAS Data Set ‘StJohns’ | Site | PatientID | FirstNm | LastNm | Sex | 1 | St Johns | 203 | Daniel | Taylor | M | 2 | St Johns | 206 | Helen | Davis | F | 3 | St Johns | 208 | Betty | Smith | f | … | … | … | … | … | … |
SAS Data Set ‘CM’ | Institution | SubjID | Name | Gender | 1 | City Medics | 102 | Wilson, Steven | Male | 2 | City Medics | 105 | Moore, Chris | male | 3 | City Medics | 109 | Jackson, Sharon | Female | … | … | … | … | … |
Write SAS code which will combine the 2 data sets above into the single data set named ‘AllSites’ with attributes and values exactly as shown below. SAS Data Set ‘AllSites’ | Institution | SubjID | Name | SexCd | 1 | City Medics | 102 | Wilson, Steven | M | 2 | City Medics | 105 | Moore, Chris | M | 3 | City Medics | 109 | Jackson, Sharon | F | 4 | St Johns | 203 | Taylor, Daniel | M | 5 | St Johns | 206 | Davis, Helen | F | 6 | St Johns | 208 | Smith, Betty | F | … | … | … | … | … |
|
Here are the datelines:
DATA StJohns;
INFILE DATALINES;
INPUT Site $8.
PatientID
FirstNm $
LastNm $
Sex $;
DATALINES;
St Johns 203 Daniel Taylor M
St Johns 206 Helen Davis F
St Johns 208 Betty Smith f
;
DATA CM;
INFILE DATALINES DSD DLM=' ';
INPUT Institution :$11.
SubjID
Name :$15.
Gender :$6.;
DATALINES;
'City Medics' 102 'Wilson, Steven' Male
'City Medics' 105 'Moore, Chris' male
'City Medics' 109 'Jackson, Sharon' Female
;