BookmarkSubscribeRSS Feed
torvin10
Calcite | Level 5

I have to merge these two sets of data, which contains exactly the same data, but written in different ways:

Offsite data:

* (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?

2 REPLIES 2
Reeza
Super User

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:

Offsite data:

* (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?


 

torvin10
Calcite | Level 5

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. 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1027 views
  • 0 likes
  • 2 in conversation