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
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
I do this but it does not work
PROC TRANSPOSE
DATA=have;
OUT=want ;
by secid;
RUN;
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;
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 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: