BookmarkSubscribeRSS Feed
nroux
Calcite | Level 5

Hello, 

I am a novice SAS user and would much appreciate any advice regarding this error:

 
WARNING: The variable _1 in the DROP, KEEP, or RENAME list has never been
referenced.
 
The error shows up with the code:
 
proc transpose data=ewretdat out=ewretdat2
(rename = (_1=SELL _2=PORT2 _3=PORT3 _4=PORT4 _5=PORT5
_6=PORT6 _7=PORT7 _8=PORT8 _9=PORT9 _10=BUY));
by date;
id momr;
var ewret;
run;
 
The content of the momr column which I am transposing is a simple numerical integer (1 to 10). This issue is preventing me from referencing these new columns to pursue calculations.
 
Thanks in advance,
 
Nicolas
 
 
4 REPLIES 4
Patrick
Opal | Level 21

@nroux

The warning indicates that Proc Transpose doesn't create a variable _1. May be your variable momr never has a value of 1 in your source data.

 

Run your Proc Transpose statement first without the rename and check what variable names you actually get.

art297
Opal | Level 21

If you have to run the transpose on a number of datasets where not all momr values will be present each time, here is another way to assign the variable names you want:

 

data ewretdat;
  input momr ewret date date9.;
format date date9.; cards; 1 1 01apr2017 2 1 01apr2017 1 2 1may2017 2 2 01may2017 ; proc format; value momr 1=SELL 2=PORT2 3=PORT3 4=PORT4 5=PORT5 6=PORT6 7=PORT7 8=PORT8 9=PORT9 10=BUY ; run; proc transpose data=ewretdat out=ewretdat2; by date; id momr; var ewret; format momr momr.; run;

Art, CEO, AnalystFinder.com

 

s_lassen
Meteorite | Level 14

@art297: There is a much easier way. Use the PREFIX= option in PROC TRANSPOSE:

proc transpose data=ewretdat out=ewretdat2 prefix=PORT;
  by date;
  id momr;
  var ewret;
run;

@art297 wrote:

If you have to run the transpose on a number of datasets where not all momr values will be present each time, here is another way to assign the variable names you want:

 

data ewretdat;
  input momr ewret date date9.;
format date date9.; cards; 1 1 01apr2017 2 1 01apr2017 1 2 1may2017 2 2 01may2017 ; proc format; value momr 1=SELL 2=PORT2 3=PORT3 4=PORT4 5=PORT5 6=PORT6 7=PORT7 8=PORT8 9=PORT9 10=BUY ; run; proc transpose data=ewretdat out=ewretdat2; by date; id momr; var ewret; format momr momr.; run;

Art, CEO, AnalystFinder.com

 


 

Astounding
PROC Star

While the variables won't always exist, you can get rid of the warning pretty easily.  Add this to your program:

 

options dkrocond=nowarn;

 

That won't add the missing variables, but it will get rid of the warning.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 799 views
  • 0 likes
  • 5 in conversation