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. 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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