BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,

We are getting data of a particular person details in segments and I want to combine all info pertaining to single record.

For $example, data is like this: (delimited by pipe)

abc|tom^j^smith|23^elms street^manchester^MA|xxxxxx|yyyyyy
def|E|2|PPO|Male
ghi|blah1|blah2|blah3

So I want to combine all data into a single record, which is coming in segments. abc, def, ghi are repeating in the file and have many records. How to do this in sas?

thanks,
2 REPLIES 2
Patrick
Opal | Level 21
Is the result a text file or a SAS dataset?

For a text file:
Have a look at the meaning of @ and @@ for the input and put statement.

For a dataset:
Have a look at 'Proc Transpose' or at the OUTPUT statement.

To denormalise a table is often not a good idea - avoid it if you don't have very good reasons for it.

Cheers, Patrick
GertNissen
Barite | Level 11
Try this

data test;
length a1-a14 $20;
infile datalines dlm='|';
input a1-a14 :$20.;
datalines;
abc|tom^j^smith|23^elms street^manchester^MA|xxxxxx|yyyyyy
def|E|2|PPO|Male
ghi|blah1|blah2|blah3
abc|tom^j^smith|23^elms street^manchester^MA|xxxxxx|yyyyyy
def|E|2|PPO|Male
ghi|blah1|blah2|blah3
abc|tom^j^smith|23^elms street^manchester^MA|xxxxxx|yyyyyy
def|E|2|PPO|Male
ghi|blah1|blah2|blah3
abc|tom^j^smith|23^elms street^manchester^MA|xxxxxx|yyyyyy
def|E|2|PPO|Male
ghi|blah1|blah2|blah3
;
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1178 views
  • 0 likes
  • 3 in conversation