BookmarkSubscribeRSS Feed
paddyb
Quartz | Level 8

i have to transpose this dataset

Obs    usubjid   idvar       idvarval   qnam             qval
1        100        vsspid     1254        error             intermittent connection
2        100        vsrefid     R12         bpstdt           2010-01-15T15:30
3        100        vsrefid     R12         bpstdt           2010-01-15T16:30
4        100        vsrefid     L12         bpstdt            2010-01-15T15:35
5        100        vsrefid     L12         bpstdt            2010-01-15T16:35

 

i am doing this to transpose and getting error bpstdt occurs twice,how to fix it





5 REPLIES 5
Kurt_Bremser
Super User

I wrote this code to create your dataset from a data step:

data suppvs;
infile cards dlm=',';
input usubjid idvar $ idvarval $ qnam $ qval :$25.;
cards;
100,vsspid,1254,error,intermittent connection
100,vsrefid,R12,bpstdt,2010-01-15T15:30
100,vsrefid,R12,bpstdt,2010-01-15T16:30
100,vsrefid,L12,bpstdt,2010-01-15T15:35
100,vsrefid,L12,bpstdt,2010-01-15T16:35
;
run;

Please check if that resembles your data. Note that this is the proper way to post example data, as one can also set all attributes in a data step; from a simple listing we have to guess those.

 

And please post your intended result. The ERROR is genuine as it should be. You use qnam as ID, and a ID variable in a transpose must be unique for every by group.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Out of interest, why?  That looks like a VS domain from CDISC and that is in the correct format - long rather than wide.  You will find it difficult to transpose as there are mutiple rows with the same data, so first you would need some further identifier to identify unique records.

paddyb
Quartz | Level 8
 
RW9
Diamond | Level 26 RW9
Diamond | Level 26

I belive your SDTM domains are not correctly mapped then.  Within the SUPPxx domain IDVAR, IDVARVAL, QNAM have to be unique.  In the example you provide there is no way of uniquely identifying obs 2 from 3, and 4 from 5.  So, QNAM variable holds the variable which will be created and QVAL the data to put into that variable, however you have 2 of the same variable (BPSTDT) for each IDVARVAL=R12 or L12.  Something seems to be wrong in the mapping.  Maybe QNAM should be BPSTDT1 and BPSTDT2 respectively for 2/3 and 4/5?

 

Obs    usubjid   idvar       idvarval   qnam             qval
1        100        vsspid     1254        error             intermittent connection
2        100        vsrefid     R12         bpstdt           2010-01-15T15:30
3        100        vsrefid     R12         bpstdt           2010-01-15T16:30
4        100        vsrefid     L12         bpstdt            2010-01-15T15:35
5        100        vsrefid     L12         bpstdt            2010-01-15T16:35
Astounding
PROC Star

There is no quick syntax fix.  You will have to display what you want the result to be, for someone to properly change the code..  

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
  • 5 replies
  • 987 views
  • 1 like
  • 4 in conversation