BookmarkSubscribeRSS Feed
sasphd
Lapis Lazuli | Level 10

hello 

Have

secid   01-2020  02-2020 03-2020

1            0.3            0.2          0.6

2               0.25        0.68       0.95

want

secid  caldt           mret

1         01-2020     0.3

1          02-2020       0.2

1         03-2020      0.6

2        01-2020       0.25

2          02-2020      0.68

2         03-2020      0.95

 

3 REPLIES 3
Reeza
Super User

Have you tried a PROC TRANSPOSE? If so, please show your code.
Your variable names are not valid SAS names so you may want to consider providing sample data that's similar to your actual data structure.

 

Transposing data tutorials:
Wide to Long:
https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-wide-to-long-using-proc-transpose/

https://stats.idre.ucla.edu/sas/modules/reshaping-data-wide-to-long-using-a-data-step/


@sasphd wrote:

hello 

Have

secid   01-2020  02-2020 03-2020

1            0.3            0.2          0.6

2               0.25        0.68       0.95

want

secid  caldt           mret

1         01-2020     0.3

1          02-2020       0.2

1         03-2020      0.6

2        01-2020       0.25

2          02-2020      0.68

2         03-2020      0.95

 


 

 

sasphd
Lapis Lazuli | Level 10

I do this but it does not work

 

PROC TRANSPOSE
DATA=have;
OUT=want ;
by secid;
RUN;

Reeza
Super User

You didn't specify any variables in that list. Try explicitly listing the variables you want to transpose and include them in the VAR statement.

Additionally, an array method in a data step may be simpler for you to code, update and understand and may be worth a shot. The tutorial in my first post has the details.

 

Also, please explain what " does not work" means. That could mean anything from your SAS installation crashed to errors in the log to it worked but you checked the wrong output file or expected results in the results pane which does not happen. And include your log, especially if there are warnings or errors.

 


@sasphd wrote:

I do this but it does not work

 

PROC TRANSPOSE
DATA=have;
OUT=want ;
by secid;
RUN;


 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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