Help using Base SAS procedures

why am I receiving a message WARNING: The variable _1 in the DROP, KEEP, or RENAME list has never been referenced.

Reply
Occasional Contributor
Posts: 5

why am I receiving a message WARNING: The variable _1 in the DROP, KEEP, or RENAME list has never been referenced.

Hi,

I am running a program on SAS Enterprise Guide, that used to work everytime on earlier versions of SAS. When I get to the step below I receive the following message

data PosteriorProbabilities (keep=Site %VarStrg2(_,&MinGrp,&MaxGrp));

    set TestOut;

run;

WARNING: The variable _1 in the DROP, KEEP, or RENAME list has never been referenced.

WARNING: The variable _2 in the DROP, KEEP, or RENAME list has never been referenced.

WARNING: The variable _3 in the DROP, KEEP, or RENAME list has never been referenced.

NOTE: There were 44 observations read from the data set WORK.TESTOUT.

NOTE: The data set WORK.POSTERIORPROBABILITIES has 44 observations and 1 variables.

NOTE: DATA statement used (Total process time):

      real time           0.02 seconds

      cpu time            0.00 seconds

Can anyone suggest why this would be happening? After this non of the tables in the program generate properly.

I am  getting desperate.

Kind regards

Claire

Super User
Posts: 3,100

Re: why am I receiving a message WARNING: The variable _1 in the DROP, KEEP, or RENAME list has never been referenced.

Your dataset TESTOUT does not contain the variables listed in the warnings. It looks like it only contains one variable: SITE.

You will need to look at prior steps in your program to understand why these variables are not present.

Occasional Contributor
Posts: 5

Re: why am I receiving a message WARNING: The variable _1 in the DROP, KEEP, or RENAME list has never been referenced.

Thank you. I am an old user of this script but never had to understand it before, so I am slowly figuring out how to read and understand the script. I have gone back through and had a look at the testOut and of the 22 columns there are three called 1,2 and 3. The posterior probability file also has columns labelled 1,2, and 3. Note that there is no underscore preceeding the numbers. Does the underscore matter?

Super User
Posts: 6,927

Re: why am I receiving a message WARNING: The variable _1 in the DROP, KEEP, or RENAME list has never been referenced.

1, 2 or 3 are _not_ valid SAS variable names (unless you use the '1'n construct, which I advise against). So what you see is most probably the variable label, which can be any text.

Valid SAS names need to start with a character or an underline.

Run a proc contents on the dataset to see what is actually in there.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
PROC Star
Posts: 1,226

Re: why am I receiving a message WARNING: The variable _1 in the DROP, KEEP, or RENAME list has never been referenced.

I feel like you posted this question within the last couple days and got an answer, but I can't find it now....

My memory is your macro %VarStrg2 is designed to make a list.  So if you submitted: %put %VarStrg2(Foo,1,5) ; the log would show:

Foo1 Foo2 Foo3 Foo4 Foo5

Is that right?

So in you program, it looks like the value of &MinGrp is 1 and the value of &MaxGrp is 3, so your DATA step becomes:

data PosteriorPriorities(keep=Site _1 _2 _3) ;

   set TestOut ;

run ;

But, since the TestOut data set does not have variables named _1 _2 or _3, you end up with the PosteriorPriorities data set having only one variable, Site. See the log: "44 observations and 1 variables"

So if you really expect TestOut to have variables named _1 _2 _3, I would look into how that data set was made.

Occasional Contributor
Posts: 5

Re: why am I receiving a message WARNING: The variable _1 in the DROP, KEEP, or RENAME list has never been referenced.

Thanks Quentin,

I had previously posted this on StackOverflow a few days ago but did not know there had been replies on that forum until your post on here. So apologies if I am accidentally over posting. You are correct in your interpretation of the macro, and the testout data set is  the output of a discrim procedure.

Cheers

PROC Star
Posts: 1,226

Re: why am I receiving a message WARNING: The variable _1 in the DROP, KEEP, or RENAME list has never been referenced.

Hi, thanks for mentioning you had posted on S.O.  I knew I had seen it *somewhere*.  I think it's fair to post there and here, particularly since you allowed a few days for folks there to help first.  They are different audiences, though of course plenty of overlap.  I had thought you had posted *here* already and then deleted it, which of course would be poor netiquette.

Would follow Kurt's advice of running proc contents on TestOut to see what your variable names are.

Respected Advisor
Posts: 3,777

Re: why am I receiving a message WARNING: The variable _1 in the DROP, KEEP, or RENAME list has never been referenced.

I think if you set OPTIONS VALIDVARNAME=V7; it will fix your program.

Occasional Contributor
Posts: 5

Re: why am I receiving a message WARNING: The variable _1 in the DROP, KEEP, or RENAME list has never been referenced.

Thank you so much

This has fixed the script.

Kind regards

Claire

Contributor
Posts: 63

Re: why am I receiving a message WARNING: The variable _1 in the DROP, KEEP, or RENAME list has neve

@barelythere- Can you please post the answer , as I am also facing the same issue .

 

and  not able to fix it.

 

Thanks & Regards,

Ritesh Srivastava

Ask a Question
Discussion stats
  • 9 replies
  • 6107 views
  • 6 likes
  • 6 in conversation