Help using Base SAS procedures

Transpose data

Accepted Solution Solved
Reply
Contributor
Posts: 28
Accepted Solution

Transpose data

[ Edited ]

Hello, I am trying to create table using proc transpose to generate the things below. I dont know how to just convert the CODE to horizen but still fits the application_number and action and also the appstatusdate will change with it.  If anyone could help, I will appreciate that. Thanks.

 

 

 


Accepted Solutions
Solution
‎01-18-2017 08:56 AM
Respected Advisor
Posts: 4,934

Re: Transpose data

Posted in reply to septemberbulb

Could be as simple as:

 

proc transpose data=have out=want(drop=_name_) prefix=code;
by APPLICATION_NUMBER APPSTATUSDATE ACTION notsorted;
var CODE;
run;
PG

View solution in original post


All Replies
Trusted Advisor
Posts: 1,585

Re: Transpose data

Posted in reply to septemberbulb

proc sort data=have; by application_numbar appstatusdate action code; run;

data want;

 set have;

    by application_numbar appstatusdate action;

        length code1 code2 $1;

        retain code1 code2;

        if first.action then do;

           code1=' '; code2=' ';

       end;

       if code='f' then code1=code;

       if code='s' then code2=code;

       if last.action then output;

run; 

Super User
Posts: 19,869

Re: Transpose data

Posted in reply to septemberbulb

How do you identify a 'group' or know that the two rows go together?

Respected Advisor
Posts: 4,934

Re: Transpose data

Posted in reply to septemberbulb

Please post a machine readable version of your data. Can't do any processing on a picture of your data.

PG
Contributor
Posts: 28

Re: Transpose data

[ Edited ]
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      

hope to change different code to a new column. thanks

Solution
‎01-18-2017 08:56 AM
Respected Advisor
Posts: 4,934

Re: Transpose data

Posted in reply to septemberbulb

Could be as simple as:

 

proc transpose data=have out=want(drop=_name_) prefix=code;
by APPLICATION_NUMBER APPSTATUSDATE ACTION notsorted;
var CODE;
run;
PG
Contributor
Posts: 28

Re: Transpose data

Thank you very much. It works.
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 263 views
  • 0 likes
  • 4 in conversation