Help in exploding the data

Reply
N/A
Posts: 0

Help in exploding the data

hi ,
I have a dataset in format below:
ID Vi PRocedure
1 1 ABC
1 1 DEF
1 1 FCG
1 2 FCG
1 2 KKR

when I transpose this using proc transpose prefix=proc; by id vi;var procedure;run;

I get

ID Vi Proc1 Proc2 Proc3
1 1 ABC DEF FCG
1 2 FCG KKR .

actually what I need is something like this..

ID Vi ABC DEF FCG KKR
1 1 yes yes yes no
1 2 no no yes yes

I'm not sure how to get to here in my final dataset..

Appreciate for you help.

Eddie
Super Contributor
Super Contributor
Posts: 3,174

Re: Help in exploding the data

Assign a numeric variable to 1 for each observation, which you will use with transposing your data. Also, use the ID statement specifying your PROCEDURE variable to take the column/variable name.

Then use a PROC FORMAT to assign 1=YES and OTHER=NO for the numeric variable, applied with a FORMAT statement.


Scott Barry
SBBWorks, Inc.

SAS Procedures Guide: The TRANSPOSE Procedure
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a000063661.htm
N/A
Posts: 0

Re: Help in exploding the data

Hy Scott,
Great..this is working. Actually I was trying out using 2 D( visits * Procedure) arrays and almost lost few hair.. this approach was very simple..

Appreciate your quick help...

Thanks.


Addy
Post a Question
Discussion Stats
  • 2 replies
  • 280 views
  • 0 likes
  • 2 in conversation