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

I transposed the following data and included DROP = _NAME_ to drop the variable that was formerly used to describe the labels of a set of values:

Original list of variables: SSN, VisitDt, Measure, Value

 

PROC TRANSPOSE
       DATA = WORK.V1
       OUT = WORK.V2 (DROP = _NAME_
                                                  RENAME = (COL1 = HtIn
                                                                      COL2 = WtKg
                                                                      COL3 = SBP
                                                                      COL4 = DBP)
                                                  );
       VAR Value;
       BY SSN VisitDt;

RUN;

 

The new list of variables is:  SSN, VisitDt, _LABEL_, HtIn, WtKg, SBP, DBP

 

Why is _LABEL_ in the output? Shouldn't it have dropped? Any ideas on how to fix this? Thx!

1 ACCEPTED SOLUTION

Accepted Solutions
unison
Lapis Lazuli | Level 10

If no other variables in output start with "_", then drop all _NAME_ _LABEL_ by specifying DROP= _:

Example:

proc transpose data=sashelp.class out=want(drop=_:);
by name;
id sex;
var height;
run;
-unison

View solution in original post

3 REPLIES 3
Reeza
Super User
Why would you assume that _label_ would be dropped if _name_ was dropped? It's not mentioned in the DROP statement so if it's the output without any other DROP/RENAME I'd expect that you'd have to explicitly list it in the DROP statement as well.

FYI - personally I'd consider it dangerous to rename variables in that fashion, I'd highly recommend the usage of an ID and/or IDLABEL statement in your PROC TRANSPOSE code.
kbauphealth20
Fluorite | Level 6

That's good to know. I was taught that it improves efficiency to rename in the set statement. Is the concern incorrectly renaming a variable and making it permanent?

unison
Lapis Lazuli | Level 10

If no other variables in output start with "_", then drop all _NAME_ _LABEL_ by specifying DROP= _:

Example:

proc transpose data=sashelp.class out=want(drop=_:);
by name;
id sex;
var height;
run;
-unison

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 6340 views
  • 8 likes
  • 3 in conversation