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 &...
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.
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;
Looks like you are missing a '.' to separator.
proc copy in=LIB03 out=WORK;
select FILE_&l2numshortdate..dbf;
run;
@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.
yeah, i tried it with and without the double dots and neither worked.
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.
yeah, what they said below...
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: ¯ovar.dbf; %put With two dots: ¯ovar..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.
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.
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;
PROC COPY is for SAS files (datasets, views, catalogs); A .dbf (dBase) is NOT a SAS file, it is an external file.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.