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

i am trying to build a process that uses last months file to create this months file.  for some reason my variable in proc copy is not working.  the error i get is...


560 proc copy in=LIB03 out=WORK;
561 select FILE_&l2numshortdate.dbf;
_
22
200
WARNING: Apparent symbolic reference L2NUMSHORTDATE not resolved.
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, (, -, /, :.
ERROR 200-322: The symbol is not recognized and will be ignored.
562 run;

 

i cannot figure it out.  i am certain i have used very similar code before but it is not working here...code below...

 

data _null1_;
td00=today();
td01=intnx('month',today(),-5);
td02=intnx('month',today(),-6);
td03=intnx('month',today(),-7);
ytrd00=put(td00,YYMMN.);
ytrd01=put(td01,YYMMN.);
ytrd02=put(td02,YYMMN.);
ytrd03=put(td03,YYMMN.);
ytrd04=put(td04,YYMMN.);
call symput('l0numshortdate',ytrd00);
call symput('l1numshortdate',ytrd01);
call symput('l2numshortdate',ytrd02);
call symput('l3numshortdate',ytrd03);
run;

 

LIBNAME LIB01 '/sas/loc_01/files/';
LIBNAME LIB02 '/sas/loc_02/files/';


proc copy in=LIB01 out=WORK;
select ARCHIVE;
run;


proc copy in=LIB02 out=WORK;
select FILE_&l2numshortdate.dbf;
run;

 

the first proc copy is running but  the second fails at the &...

1 ACCEPTED SOLUTION

Accepted Solutions
me55
Quartz | Level 8
well, i solved my own problem. i had to wo that issue...

View solution in original post

16 REPLIES 16
PaigeMiller
Diamond | Level 26

Please do not show us portions of the log separated from the code. Please do show us the ENTIRE log for this sequence of code, with nothing chopped out, 100% of it, the CODE as it appears in the log, the NOTEs, the ERRORs, the WARNINGs, all of the log for this sequence of code.

 

Please copy the log as text and paste it into the window that appears when you click on the </> icon. DO NOT SKIP THIS STEP. This preserves the formatting and makes the log more readable and more usable.

--
Paige Miller
AMSAS
SAS Super FREQ

Add the following at the top of the code, re-run, check the log and post the log to this thread

options mprint symbolgen mlogic;
me55
Quartz | Level 8
yeah, that changed nothing...
r_behata
Barite | Level 11

Looks like you are missing a '.' to separator.

 

 

proc copy in=LIB03 out=WORK;
    select FILE_&l2numshortdate..dbf;
 run;

 

 

 

andreas_lds
Jade | Level 19

@r_behata wrote:

Looks like you are missing a '.' to separator.

 

 

proc copy in=LIB03 out=WORK;
    select FILE_&l2numshortdate..dbf;
 run;

 


No, not in this case. With the extra dot an illegal dataset-name would be the result.

me55
Quartz | Level 8

yeah, i tried it with and without the double dots and neither worked.  

Kurt_Bremser
Super User

Combine your code that sets the macro variable with the PROC COPY code, and use the option 

options mprint mlogic symbolgen;

%let .....

proc copy .....

and then post the complete log from that into a window opened with the </> button.

me55
Quartz | Level 8

yeah, what they said below...

 

ballardw
Super User
561 select FILE_&l2numshortdate.dbf;
_
22
200
WARNING: Apparent symbolic reference L2NUMSHORTDATE not resolved.

So, where do you define a macro variable named "l2numshortdate"? That error means that you have not created the macro variable, or attempted to and failed.

 

Also, the . is used as an end of macro variable marker. If the file that you expect to use needs a period after a macro variable you need to double them up. Please run the following code and read the log.

%let macrovar = Sometext;

%put Without two dots: &macrovar.dbf;
%put With two dots: &macrovar..dbf;

Please when posting copied text from the log paste it into a code box opened using the </> icon on the forum. That will preserve the formatting of the text making it easier to read and keep the locations of any diagnostic characters provided by SAS in the correct place relative to the code.

me55
Quartz | Level 8

this is multiple issues...the first was, i had to change the program location of the variables.  when i added the variables to the process flow in the correct spot in the project tree window, that did not change the order when they are run so when i added the new program, it added to the end of the process flow and so that is why it was not resolving.  

 

so, i corrected that and now i am getting a new issue which i dont really understand.  so...

 

variable definition...

data _null1_;
	options mprint symbolgen mlogic;
	td00=today();
  	td01=intnx('month',today(),-5);
  	td02=intnx('month',today(),-6);
	td03=intnx('month',today(),-7);
	ytrd00=put(td00,YYMMN.);
	ytrd01=put(td01,YYMMN.);
	ytrd02=put(td02,YYMMN.);
	ytrd03=put(td03,YYMMN.);
	ytrd04=put(td04,YYMMN.);
	call symput('l0numshortdate',ytrd00);
	call symput('l1numshortdate',ytrd01);
	call symput('l2numshortdate',ytrd02);
	call symput('l3numshortdate',ytrd03);
run;

code to run it...

LIBNAME LIB01 '/loc_01/';
LIBNAME LIB02 '/loc_02/';

proc copy in=LIB01 out=WORK;
	select FILE_ARCHIVE;
run;

%let FILEA_file=FILEA_&l2numshortdate..dbf;

proc copy in=LIB02 out=WORK;
	select &FILEA_file;
run;

resulting error...

25         GOPTIONS ACCESSIBLE;
SYMBOLGEN:  Macro variable L2NUMSHORTDATE resolves to 202006
26         
27         %let FILEA_file=FILEA_&l2numshortdate..dbf;
28         
29        


30         proc copy in=LIB02 out=WORK;
31         	
SYMBOLGEN:  Macro variable FILEA_FILE resolves to FILEA_202006.dbf
31       !  select &FILEA_file;
NOTE: Line generated by the macro variable "FILEA_FILE".
31          FILEA_202006.dbf
            _______________
            22
            201
ERROR 22-322: Expecting a name.  
ERROR 201-322: The option is not recognized and will be ignored.
32         run;

what am i missing here?  i tried putting the variable inside the proc copy and as a macro and i keep getting the same error.  

Tom
Super User Tom
Super User

You are using PROC COPY.  So the names you want to list in the SELECT statement are the names of MEMBERS of the LIBREF listed in the IN= option.  Member names do NOT contain special characters like periods.

 

What are you trying to do? 

Why are you sticking DBF extension onto the member name here?

What members exist in LIB02?

Run PROC CONTENTS to see what is there.

proc contents data=lib02._all_; run;
me55
Quartz | Level 8
i am trying to copy a file that ends with a date. so it is FILE_YYYYMM from its home which is LIB02 to my work directory. i will not hard code the date and since this same format has worked in many other instances, i figured it would work here. the file is a dbf, that is why i am putting the dbf extension on there.
me55
Quartz | Level 8
well, i solved my own problem. i had to wo that issue...

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!

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
  • 16 replies
  • 1524 views
  • 2 likes
  • 8 in conversation