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?
What type of output are you looking for, a text file or a SAS dataset? Do already have these read into SAS datasets? What is the original source and can you read those in already or is that part of the problem you’re facing? This was posted on SO and a solution provided, if that didn’t work, please outline how.
You say merge, but your code only reads in a data set so have you attempted to merge these at all so far?
@torvin10 wrote:
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?
Im trying to make a SAS data file which contains five variables. The original source is a .txt document. And i couldn´t find the solved problem that you mentioned.
I´ve tried merging the datasets by doing so:
data i ii;
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
A123 4Mar1989 8,6,00
***************
A037 23Jun1957 21,450
**************
M015 19Sep1977$17,500
***********
;
run;
However this creates a set where the * also is a part of the dataset, which is unwanted.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.