DATA Step, Macro, Functions and more

How to output data as a single record

Reply
N/A
Posts: 0

How to output data as a single record

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,
Respected Advisor
Posts: 4,173

Re: How to output data as a single record

Posted in reply to deleted_user
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
SAS Employee
Posts: 174

Re: How to output data as a single record

Posted in reply to deleted_user
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;
Ask a Question
Discussion stats
  • 2 replies
  • 117 views
  • 0 likes
  • 3 in conversation