Hi everyone, there is an obvious (to someone other than myself) syntax problem with the code below (SAS 9.4) that will not allow SAS to recognize the filename "predict_2_I&&J (error is file does not exist). Both files are created within the macro. Could someone please point out the syntax or other failure in my code below? Thank you, Rick
proc sql;
create table &ts_fcst_&I&J_ as
select * from
ts_2_&I&J as a inner join predict_2&I&J as b on
a.group=b.group and a.cvrank=b.cvrank;
Try adding the period to indicate the end of a macro variable? Note that I can't tell if your macro variable is ts or ts_fcst or ts_fcst_1_3 with i=3 and j=3......and neither can the compiler.
table &ts._fcst_&I.&J._
Have you also ran your code with the debugging options on to see how the compiler is seeing it?
options mprint symbolgen;
@rfrancis wrote:
Hi everyone, there is an obvious (to someone other than myself) syntax problem with the code below (SAS 9.4) that will not allow SAS to recognize the filename "predict_2_I&&J (error is file does not exist). Both files are created within the macro. Could someone please point out the syntax or other failure in my code below? Thank you, Rick
proc sql;
create table &ts_fcst_&I&J_ as
select * from
ts_2_&I&J as a inner join predict_2&I&J as b on
a.group=b.group and a.cvrank=b.cvrank;
What are the values of &i and &j?
Also your question text uses: "predict_2_I&&J." which is indeed a very different thing than "predict_2_&I&J
If you actually have &&J when the macro processor sees two & it "holds" the first one then resolves &J. The "uses" the held & to resolve.
So if &j is CAT then &&J =>&Cat. Which would thrown an error if you do not have a macro variable &Cat defined.
HInt: when you get an error copy the proc or data step code will all the notes and errors from the log and paste into a code box opened on the forum with the </> icon.
The code box is important to keep the message windows from reformatting text and moving the diagnostic characters that frequently appear with error messages.
Here they are:
Thank you!!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.