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;

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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