Reputation: 43
I have to merge these two sets of data, which contains exactly the same data, but written in different ways:
* (i);
A123 4Mar1989 8,60000
A037 23Jun1957 21,45000
M015 19Sep1977 17,50000
* (ii);
A123 4Mar1989 8,6,00
***************
A037 23Jun1957 21,450
**************
M015 19Sep1977$17,500
***********
The first record should have
ID = "A123", DEPT = "A", BIRTHDAY = 10655, YEAR = 1989, SALARY = 8600
So far my approach has been(which doesn´t work):
data i;
input $ID $Dep $BIRTHDAY $YEAR $SALARY;
datalines;
A123 4Mar1989 8,60000
A037 23Jun1957 21,45000
M015 19Sep1977 17,50000
;
run;
Any suggestions?
Upvotes: 1
Views: 97
Reputation: 9569
Try this:
data i;
input DEPT $1. @1 ID $ BIRTHDAY :date9. +(-5) YEAR :8. SALARY comma10.0;
datalines;
A123 4Mar1989 8,60000
A037 23Jun1957 21,45000
M015 19Sep1977 17,50000
;
run;
This uses formatted input with pointer controls to double back over parts that need to be read twice. Please refer to the documentation for the input statement for further details.
You could also use substr
to extract DEPT
from ID
, or the year
function to extract that from BIRTHDAY
.
Upvotes: 2