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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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