proc transpose data = cert.trials out = transtrials1; var cholesterol triglyc uric; id name testdate; run; proc print data = transtrials1; run;
the output like this:
proc transpose data = cert.trials out = transtrials1; var cholesterol triglyc uric; id name ; run; proc print data = transtrials1; run;
please look at the red part , I place the variable name instead of the two variables 'name' and ' testdate' , and then it doesn't work , why ?
The important thing to do is look at your LOG.
ID with duplicates for the BY group are problems.
Consider this small example:
data junk; input x y z; datalines; 1 2 3 1 2 4 1 2 5 2 1 3 2 2 5 ; proc transpose data=junk out=example; by x; id y; var z; run;
Which in the log for proc transpose shows:
743 id y; 744 var z; 745 run; ERROR: The ID value "_2" occurs twice in the same BY group. ERROR: The ID value "_2" occurs twice in the same BY group. NOTE: The above message was for the following BY group: x=1 WARNING: 1 BY groups omitted due to earlier errors.
Did you see a similar set of ERROR: messages for values of NAME in your second example in your log.
There is an option for the Proc Transpose statement, LET that allows multiple identical values for the ID variable(s).
However the result is seldom what you actually want.
747 proc transpose data=junk out=example 748 let ; 749 by x; 750 id y; 751 var z; 752 run; WARNING: The ID value "_2" occurs twice in the same BY group. WARNING: The ID value "_2" occurs twice in the same BY group. NOTE: The above message was for the following BY group: x=1 NOTE: There were 5 observations read from the data set WORK.JUNK. NOTE: The data set WORK.EXAMPLE has 2 observations and 4 variables.
The duplicate values are now warnings but look at the output data set and see if it looks like what you might want.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.