I have two datasets (SM1 and SM3) that I inner merged in SAS Studio using the following code: /** Import the CSV file. **/
FILENAME CSV "/folders/myfolders/sasuser.v94/SM1 Coded Data.csv" TERMSTR=CRLF;
PROC IMPORT DATAFILE=CSV
OUT=SM1
DBMS=CSV
REPLACE;
RUN;
/**Keep only the variables we want for this test**/
DATA SM1;
set SM1;
keep SUID LVL ESL URM SE1_A TV1_A IGO1_A EGO1_A CLB1_A;
run;
/** sort data **/
proc sort data=SM1;
by SUID;
run;
/** Import the CSV file. **/
FILENAME CSV "/folders/myfolders/sasuser.v94/SM3 Coded Data.csv" TERMSTR=CRLF;
PROC IMPORT DATAFILE=CSV
OUT=SM3
DBMS=CSV
REPLACE;
RUN;
/**Keep only the variables we want for this test**/
DATA SM3;
set SM3;
keep SUID LVL ESL URM SE3_A TV3_A IGO3_A EGO3_A CLB3_A;
run;
/** sort data **/
proc sort data=SM3;
by SUID;
run;
/** Inner Merge Data **/
data all;
merge SM1(in = left) SM3(in = right);
by SUID;
if left and right;
run; As you can see... SM1 contains the variables SUID, LVL, ESL, URM, SE1_A, TV1_A, IGO1_A, EGO1_A, and CLB1_A. SM3 contains the variables SUID, LVL, ESL, URM, SE3_A, TV3_A, IGO3_A, EGO3_A, and CLB3_A. In the last section of code I am asking SAS to merge the two data sets and only keep observations where the same SUID is found in both SM1 and SM2. Here is my question: How does SAS handle other columns that have the same name (LVL, ESL, and URM)? For example, does it save the data from SM1 or SM2? What if for a certain observation, there is data in the LVL column for SM2 but not SM1 (and vice versa)? Can you tell SAS specifically how you would like it to handle these different scenarios? Here is a picture of what the output looks like: Any information would be greatly appreciated! Thank you in advance!
... View more