BookmarkSubscribeRSS Feed
mona4u
Lapis Lazuli | Level 10

Hi all, 

I have this data set which I used proc transpose to flip it but I still not able to get the results that I want because of the Qlabel Values. 

I want to get the labels of the variables. I thought about if I use if Qname=".."then Qlabel="..."  

but I want to check if I there are shortcuts to get the label names 

 

 

my data

USUBJIDStIDCRFIDIDVARIDVARVALQORIGQEVAL
A3921024 1006 10061050A3921024 10062650261AESEQ1CRF 

 

the result that I am targeting 

QNAMEQVALQLABELIDVARIDVARVALQORIGQEVAL
USUBJIDA3921024 1006 10061050SUBJECT IDAESEQ1CRF 
StIDA3921024 1006Site idAESEQ1CRF 
CRFID2650261Crf IDAESEQ1CRF 
3 REPLIES 3
ballardw
Super User

It would help to show the code you are currently using.

 

On the PROC Transpose statement you can add the option Label= to name a variable to hold the label of transposed variables.

So I would guess that you want to add Label=Qlabel to the transpose code.

mona4u
Lapis Lazuli | Level 10
I am not sure where to add it to my code!!

proc transpose data=prep_suppae out=trans
name=QNAM;
by USUBJID IDVAR IDVARVAL QORIG ;
var StID CRFID;
run;

ballardw
Super User
proc transpose data=prep_suppae out=trans
name=QNAM label=Qlabel;
by USUBJID IDVAR IDVARVAL QORIG ;
var StID CRFID;
run;

Should have the labels for Stid and CRFid in a variable named Qlabel, IF the variables have a label assigned.

 

 

Here is a brief example with other data:

proc sort data=sashelp.class out=work.class;
   by sex age;
run;
proc transpose data=work.class
   name=qname  label=qlabel;
by sex age;
var height weight;
label height='Height at age'
      weight='Weight at age'
;
run;

The Sashelp.class data set does not have any variable labels assigned and hence no value for qlabel without them. Putting a label statement in the transpose code makes them available for the step to demonstrate the result. If only one of the variables has a label only those rows of the output have a value for  qlabel.

 

 

If you are wanting labels for other variables we'll need more information and possibly example data.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 2622 views
  • 5 likes
  • 2 in conversation