Help using Base SAS procedures

Data transformation

Reply
Super Contributor
Posts: 266

Data transformation

Dear friends looking for your help.

Kindly suggest:

Description

Pattern: A103,A104,A105,A106 belong to same person;

i need output data in form of

ID                                year month value_of_A103 value_of_A104 value_of_A105   value_of_A106

A103|A104|A105|A106  1976 M01    9.4                  596104           5739058           6335162

there thousands of id in same pattern. kindly suggest

please find attached sample file.

Attachment
Respected Advisor
Posts: 4,919

Re: Data transformation

Does this make sense to you?

data banktest;
infile "&sasforum.\datasets\banktest.txt" firstobs=2 dlm='09'x;
input ID $ year Month $ value;
run;

proc sort data=banktest; by year month id; run;

data banktemp;
length newId $64;
do until(last.month);
     set banktest; by year month id;
     if last.id then newId = catx("|", newId, Id);
     end;
do until(last.month);
     set banktest; by year month;
     output;
     end;
run;

proc transpose data=banktemp prefix=value_of_
     out=bankWant(drop=_name_);
by year month newId notsorted;
id id;

var value;
run;

proc print data=bankWant noobs; run;

PG

PG
Ask a Question
Discussion stats
  • 1 reply
  • 174 views
  • 0 likes
  • 2 in conversation