Desktop productivity for business analysts and programmers

Syntax error

Accepted Solution Solved
Reply
Contributor
Posts: 25
Accepted Solution

Syntax error

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 =


Accepted Solutions
Solution
‎04-20-2017 10:02 AM
Contributor
Posts: 33

Re: Syntax error

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;

View solution in original post


All Replies
Solution
‎04-20-2017 10:02 AM
Contributor
Posts: 33

Re: Syntax error

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;
Contributor
Posts: 25

Re: Syntax error

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;

PROC Star
Posts: 1,146

Re: Syntax error

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

Contributor
Posts: 33

Re: Syntax error

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)
Super User
Super User
Posts: 6,842

Re: Syntax error

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.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 199 views
  • 0 likes
  • 4 in conversation