Hello I am new to SAS and am trying to figure out why my code is erroring out.
WARNING: Apparent symbolic reference BEGYR not resolved.
NOTE: Line generated by the invoked macro "YEARLY_BUILD".
264 data responses_&begyr.; set outlib.responses_&begyr.; IF value ^= '' THEN value = UPCASE(value); ELSE value
_ _
8 The SAS System 10:41 Monday, April 17, 2017
22 200
200
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, /, ;, _DATA_, _LAST_, _NULL_.
ERROR 200-322: The symbol is not recognized and will be ignored.
264 ! data responses_&begyr.; set outlib.responses_&begyr.; IF value ^= '' THEN value = UPCASE(value); ELSE value
_
22
264 ! =UPCASE(value); IF questionid = 85 THEN questiondescription =
Without seeing the code around the error it looks like you're calling a macro with a variable inside. If that's the case you don't need the period after begyr.
Try this and let us know if you get further,
data responses_&begyr; set outlib.responses_&begyr;
Without seeing the code around the error it looks like you're calling a macro with a variable inside. If that's the case you don't need the period after begyr.
Try this and let us know if you get further,
data responses_&begyr; set outlib.responses_&begyr;
It still seems to be saying the same error even after taking out the period.
8 The SAS System 10:51 Monday, April 17, 2017
22 200
200
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, /, ;, _DATA_, _LAST_, _NULL_.
ERROR 200-322: The symbol is not recognized and will be ignored.
264 ! data responses_&begyr; set outlib.responses_&begyr; IF value ^= '' THEN value = UPCASE(value); ELSE value
_
22
264 ! =UPCASE(value); IF questionid = 85 THEN questiondescription =
WARNING: Apparent symbolic reference BEGYR not resolved.
ERROR: Libref OUTLIB is not assigned.
The code where the error seems to be appearing is
%let pgm = s300_MHR_ALL_Qtrs_Pull ;
%MACRO yearly_build;
data responses_&begyr;
set outlib.responses_&begyr;
IF value ^= '' THEN value = UPCASE(value);
ELSE value =UPCASE(value);
IF questionid = 85 THEN questiondescription = 'When wearing your hearing aid, can you hear people speaking without them sounding mumbled?';
ELSE questiondescription = questiondescription;
resp_yr_qtr = "&begyr.";
run;
If the macro variable &begyr doesn't have a value, the statement
data responses_&begyr.;
is illegal because a SAS dataset name can't contain a &.
It's impossible for us to tell what &begyr should be, as that's business logic. However, suppose it should be 2016.
If you put the statement
%let begyr = 2016;
immediately after the %MACRO statement, your code will compile correctly. You need to figure out how this macro variable is supposed to be set.
Tom
Here is a snippet from one of my saved macros, when calling the macro and passing 'dataset', in your case, begyr, it should look similar to this,
/*Split Dataset by number of observations*/
/*Usage, %SPLIT (DATASETNAME,OBS) - Example %SPLIT (FINAL,100000)*/
%macro split(dataset,splitby);
data _null_;
set &dataset nobs=num;
I'm calling the variable dataset by using &dataset within the macro. So yours would be like this,
/*Split Dataset by number of observations*/
/*Usage, %SPLIT (DATASETNAME,OBS) - Example %SPLIT (FINAL,100000)*/
%macro split(begyr,splitby);
data _null_;
set &begyr nobs=num;
more stuff blah blah
end the macro
%mend split;
call the macro and assign 2016 to 'begyr'
%SPLIT (2016,100)
The first message is the key one. The others are just the side effects from that.
WARNING: Apparent symbolic reference BEGYR not resolved.
You have not defined the macro variable BEGYR so you end up with a DATA statement that looks like:
data responses_&begyr.;
Which is invalid since you cannot use & in a member name.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.