BookmarkSubscribeRSS Feed
UPEN
Obsidian | Level 7

 

proc append base=work.Empty data=task.&provider ( keep = USERID provider qry RunDate); run; 

I am getting following error if I use the keep statement in the Proc append statement as 

 

 

ERROR: The variable USERID in the DROP, KEEP, or RENAME list has never been referenced.
ERROR: The variable provider in the DROP, KEEP, or RENAME list has never been referenced.
ERROR: The variable qry in the DROP, KEEP, or RENAME list has never been referenced.
ERROR: The variable Rundate in the DROP, KEEP, or RENAME list has never been referenced.

 

Work.Empty is an empty data set and does not have anything inside it. I tried to look up the syntax for keep statement in PROC Append, but no use. The error is because of the syntax? 

 

If I use a dataset with keep statement, like the following code. It is working.

 

data Prov_new (keep =USERID providerPPN qryname Rundate);
set task.&provider ;
run;
proc append force data= Prov_new base=work.empty;
run;

I want to reduce those 2 lines of code and at the same trying to figure out the issue. Please help.

2 REPLIES 2
Reeza
Super User

You have some other issue, your append works fine for me. Are you sure Empty doesn't exist?

Are you sure that all those variables are in your dataset already?

 

1223 proc append base=work.Empty data=sashelp.class ( keep = Name
1223! Age); run;

NOTE: Appending SASHELP.CLASS to WORK.EMPTY.
NOTE: BASE data set does not exist.
DATA file is being copied to BASE file.
NOTE: There were 19 observations read from the data set
SASHELP.CLASS.
NOTE: The data set WORK.EMPTY has 19 observations and 2 variables.
NOTE: PROCEDURE APPEND used (Total process time):
real time 0.12 seconds
cpu time 0.00 seconds

 

 


@UPEN wrote:

 

proc append base=work.Empty data=task.&provider ( keep = USERID provider qry RunDate); run; 

I am getting following error if I use the keep statement in the Proc append statement as 

 

 

ERROR: The variable USERID in the DROP, KEEP, or RENAME list has never been referenced.
ERROR: The variable provider in the DROP, KEEP, or RENAME list has never been referenced.
ERROR: The variable qry in the DROP, KEEP, or RENAME list has never been referenced.
ERROR: The variable Rundate in the DROP, KEEP, or RENAME list has never been referenced.

 

Work.Empty is an empty data set and does not have anything inside it. I tried to look up the syntax for keep statement in PROC Append, but no use. The error is because of the syntax? 

 

If I use a dataset with keep statement, like the following code. It is working.

 

data Prov_new (keep =USERID providerPPN qryname Rundate);
set task.&provider ;
run;
proc append force data= Prov_new base=work.empty;
run;

I want to reduce those 2 lines of code and at the same trying to figure out the issue. Please help.


 

ballardw
Super User

Your statement "Work.Empty is an empty data set and does not have anything inside it. " explains the error. If there are no variables then there is nothing to "keep" and attempting to do so generates an error.

 

Since Proc Append will not let you add any variables that are not in the base set then the keep option isn't really needed. If you want to avoid the problem of SAS not wanting to add the data when you do have varaibles not in the base set then use the FORCE option. Note the force options will not add those variables but will allow the appending of varaibles that do match the base data. If you use the force option because you know there are variables you do not want to add to the base set you might want to include the NOWARN option as well to prevent the warning SAS will put in the log that the Force option was used.

 

Also not that if you have variables of different types but same name the ones in the append set will be missing in the result. There is not conversion. And different lengths for the same variable may result in trucation.

 

 

sas-innovate-2024.png

 

Time is running out to save with the early bird rate. Register by Friday, March 1 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 4014 views
  • 0 likes
  • 3 in conversation