BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
vraj1
Quartz | Level 8

I am stuck up with transposing as i get multople observations if i try to transpose as the paramcd has multiple observations. attached code i am using and i need single observation per subject. any suggestion where am i going wrong

proc sort data=Anl1
	           out= anl2;
     by studyid usubjid paramcd aval;
run;

data Id_adds (keep=studyid usubjid aval avalc paramcd seq);
      set anl2;
      by studyid usubjid paramcd aval;
      seq+1;
       if first.paramcd then seq=1;
run;

proc transpose data=Id_adds out=Id_trans(drop=_name_ _label_) ;
      by studyid usubjid;
     id paramcd seq;
     var aval;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

This:

     id paramcd seq;

Wont work.   Update here:

data Id_adds (keep=studyid usubjid aval avalc paramcd seq);
  set anl2;
  by studyid usubjid paramcd aval;
retain seq; if first.paramcd then seq=1;
else seq+1;
paramcd=cats(paramcd,put(seq,best.)); run;

Then put:

 

proc transpose data=Id_adds out=Id_trans(drop=_name_ _label_) ;
  by studyid usubjid;
  id paramcd;
  var aval;
run;

Ie make the variable paramcd cd unique by adding the incremental number to it (when you have the sequence correct). 

View solution in original post

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

This:

     id paramcd seq;

Wont work.   Update here:

data Id_adds (keep=studyid usubjid aval avalc paramcd seq);
  set anl2;
  by studyid usubjid paramcd aval;
retain seq; if first.paramcd then seq=1;
else seq+1;
paramcd=cats(paramcd,put(seq,best.)); run;

Then put:

 

proc transpose data=Id_adds out=Id_trans(drop=_name_ _label_) ;
  by studyid usubjid;
  id paramcd;
  var aval;
run;

Ie make the variable paramcd cd unique by adding the incremental number to it (when you have the sequence correct). 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1 reply
  • 918 views
  • 0 likes
  • 2 in conversation