Help using Base SAS procedures

what is the method

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 111
Accepted Solution

what is the method

hi all,

i have the data like this

year     x

2010     50    

2010     75

now i want the output like

year      x     y

2010     50     75

can any one suggest me

thanks in advance


Accepted Solutions
Solution
‎02-16-2015 08:29 AM
Super User
Super User
Posts: 7,942

Re: what is the method

Posted in reply to Ravikumarkummari

Hi,

Proc transpose data =have out=want;

     by year;

     var x;

run;

I am not sure why you would want the columns label x y z etc. its not really conducive to further processing.  Having variables with a numeric suffix allows you to use lists e.g.

array data_to_process {3} col1-col3;

View solution in original post


All Replies
Super Contributor
Posts: 282

Re: what is the method

Posted in reply to Ravikumarkummari

Hi,

One "method" would be to process your data set by year and then only output when you get to the last year.

Documentation on by processing can be found below:

SAS(R) 9.4 Statements: Reference, Third Edition

Also, would there only ever be 2 observations per year in your original data set?

Regards,

Amir.

Solution
‎02-16-2015 08:29 AM
Super User
Super User
Posts: 7,942

Re: what is the method

Posted in reply to Ravikumarkummari

Hi,

Proc transpose data =have out=want;

     by year;

     var x;

run;

I am not sure why you would want the columns label x y z etc. its not really conducive to further processing.  Having variables with a numeric suffix allows you to use lists e.g.

array data_to_process {3} col1-col3;

🔒 This topic is solved and locked.

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

Discussion stats
  • 2 replies
  • 187 views
  • 0 likes
  • 3 in conversation