Good morning. I'm hoping someone could help me with an error I'm receiving.
I've simplified my steps as much as I can to attempt to pin down where my error is coming from but so far I've been unsuccessful.
In running the attached code I get the following error:
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,
a numeric constant, a datetime constant, a missing value, BTRIM, INPUT, PUT, SUBSTRING,
USER.
What I'm attempting to do is to initialize a variable and then use that variable in a SQL step. The first error I received was the SQL step looking for the "location_str" variable as a column in the SAS_COMM_TEST_DATA file. That was really strange since I am looking at the values within the location variable not the actual variable names. These steps seem pretty straight forward but I can't seem to determine where I've gone wrong with either error. I know there must be a better way to do this but this is what I have in an attempt to just get it to work.
I'd sure appreciate any help or advice on how to best/better proceed.
Thank you.
data _null_;
if week_day = 2 then do;
location_str = 'LOCA 1';
title_location = 'LOCA 1';
end;
call symput("location_str",location_str);
call symput("title_location",title_location);
run;
proc sql;
create table test_01 as
select a.key, a.location
from SAS_COMM_TEST_DATA as a
where a.location contains (&location_str.)
order by a.key;
quit;
I am assuming that variable location is a character string, so you must compare it to a character string. Thus you need double-quotes around the macro variable to indicate that you have a character string.
Try this
where a.location contains ("&location_str")
From now on, please when there is an error in the log, show us the ENTIRE log for that PROC or DATA step. Do not show us errors disconnected from the code as it appears in the log.
I am assuming that variable location is a character string, so you must compare it to a character string. Thus you need double-quotes around the macro variable to indicate that you have a character string.
Try this
where a.location contains ("&location_str")
From now on, please when there is an error in the log, show us the ENTIRE log for that PROC or DATA step. Do not show us errors disconnected from the code as it appears in the log.
Thank you very much.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.