题目:是[sas programming by example]的problem5-5
You have two SAS data sets, ONE and TWO. Data set ONE contains a variable called DATE1 which is a character variable in the form MM/DD/YY. (i.e. variable DATE1 is not a SAS date, which is a numerical quantity, but rather a character string of length 8.) Variables HEIGHT and WEIGHT are also contained in data set ONE. Data set TWO contains a character variable called DATE2 which is in the form ddMONyy. Data set TWO also contains the variable HR (heart rate). Write a program to merge these data sets by date, and assume that there are no duplicate dates in each of the data sets. Solve this problem two ways:
a) Use the PUT function to create a new variable in one of the data sets so that the two data sets have an identical variable to use.
我写的code:
/*5-5*/
DATA ONE;
INPUT DATE1 $ 8. HEIGHT WEIGHT;
DATALINES;
10/21/46 58 155
09/05/55 66 220
01/11/44 63 205
;
RUN;
DATA TWO;
INPUT DATE2: $7. HR;
DATALINES;
210CT46 58
11JAN44 68
05SEP55 72
;
RUN;
DATA NEWTWO;
SET TWO;
DATE1 = PUT (INPUT(DATE2, DATE7.),MMDDYY8.);
DROP DATE2;
RUN;
PROC SORT DATA=ONE;
BY DATE1;
RUN;
PROC SORT DATA=NEWTWO;
BY DATE1;
RUN;
DATA BOTH;
MERGE ONE NEWTWO;
BY DATE1;
RUN;
PROC PRINT DATA=BOTH;
TITLE'MERGE';
RUN;
我从put,input那一步的结果 date就是missing的,学渣求大神指点