New SAS User

Completely new to SAS or trying something new with SAS? Post here for help getting started.
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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