Hi all i have data in vertical format i want it in horizontal format without using proc transpose with simple approch
Why not proc transpose? It is the right tool for the job. You could easily use a data step that will be something like this. If you provided the data in a form I could copy, I could test the code, but since you didn't I'll leave it to you to fill in the details
data;
set;
by notsorted cust;
retain checking mortage saving credit_card;
if account = 'checking' then checking = balance;
... three more obvious if then assignments to make the other variables ...
if last.cust then output;
drop account balance;
run;
There are other ways, of course, to do this.
Why not proc transpose? It is the right tool for the job. You could easily use a data step that will be something like this. If you provided the data in a form I could copy, I could test the code, but since you didn't I'll leave it to you to fill in the details
data;
set;
by notsorted cust;
retain checking mortage saving credit_card;
if account = 'checking' then checking = balance;
... three more obvious if then assignments to make the other variables ...
if last.cust then output;
drop account balance;
run;
There are other ways, of course, to do this.
You do that with proc transpose, period. Use the right tool for the task.
Anything else would involve a lot of meta-programming to make it flexible vis the values in account, and therefore be stupid.
You already got a blueprint from @WarrenKuhfeld, adapt it to your needs, but you will have to expand that code everytime a new value in account appears.
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!
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.