Hi all,
I recently started using macros to create designs for my experiments. I successfully created a Balanced Incomplete Blocked Design (BIBD). Now I'm dealing with this code that should display the BIBD using the actual attribute names rather than just numbers:
data _null_;
array alts[13] $12 _temporary_ (’Update’ ’Notes’ ’Comments’ ’Wall posts’ ’Private messages’ ’Chat’ ’Groups’ ’Newsfeed’ ’Like’ ’Photos/Videos’ ’Events’ ’Gaming’ ’Fan pages’);
set sasuser.bibd; /* read design */
put alts[x1] +(-1) ’, ’ /* print each attr, comma separated */
alts[x2] +(-1) ’, ’ alts[x3] +(-1) ’, ’ alts[x4];
run;
However, I got two errors, the log says:
42 data _null_;
43 array alts[13] $12 _temporary_ (’Update’ ’Notes’ ’Comments’ ’Wall posts’ ’Private messages’
-
22
76
43 ! ’Chat’ ’Groups’ ’Newsfeed’ ’Like’ ’Photos/Videos’ ’Events’ ’Gaming’ ’Fan pages’);
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant,
a datetime constant, a missing value, iterator, (.
ERROR 76-322: Syntax error, statement will be ignored.
44 set sasuser.bibd; /* read design */
45 put alts[x1] +(-1) ’, ’ /* print each attr, comma separated */
-
22
200
46 alts[x2] +(-1) ’, ’ alts[x3] +(-1) ’, ’ alts[x4];
- -
22 22
200 200
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, arrayname, #, (,
+, /, //, ;, @, @@, OVERPRINT, _ALL_, _BLANKPAGE_, _ODS_, _PAGE_.
I suspect that both errors are due to some sort of format/versioning issue but I have not been able to understand where the problem lies. System is SAS 9.4 TS Level 1M5. I do apologise in advance if the question is mundane to the experts, I'm still a beginner. Thank you in advance for any suggestion.
Well, and not sure this matters, when I copy just the code I get funny quote marks:
data _null_; array alts[13] $12 _temporary_ (’Update’ ’Notes’ ’Comments’ ’Wall posts’ ’Private messages’ ’Chat’ ’Groups’ ’Newsfeed’ ’Like’ ’Photos/Videos’ ’Events’ ’Gaming’ ’Fan pages’); run;
When I replace those quotes with ', then the code runs fine. I would suggest starting a new session and running again, its possible you have things hanging over from previous runs, especially if it fails later on.
This worked for me:
data tmp; array alts[13] $12 _temporary_ ('Update' 'Notes' 'Comments' 'Wall posts' 'Private messages' 'Chat' 'Groups' 'Newsfeed' 'Like' 'Photos/Videos' 'Events' 'Gaming' 'Fan pages'); run;
’Private messages’ is over 12 characters. Try $ 40 .....
Well, and not sure this matters, when I copy just the code I get funny quote marks:
data _null_; array alts[13] $12 _temporary_ (’Update’ ’Notes’ ’Comments’ ’Wall posts’ ’Private messages’ ’Chat’ ’Groups’ ’Newsfeed’ ’Like’ ’Photos/Videos’ ’Events’ ’Gaming’ ’Fan pages’); run;
When I replace those quotes with ', then the code runs fine. I would suggest starting a new session and running again, its possible you have things hanging over from previous runs, especially if it fails later on.
This worked for me:
data tmp; array alts[13] $12 _temporary_ ('Update' 'Notes' 'Comments' 'Wall posts' 'Private messages' 'Chat' 'Groups' 'Newsfeed' 'Like' 'Photos/Videos' 'Events' 'Gaming' 'Fan pages'); run;
Thank you RW9, and thank you KurtBremser for pointing me to the little running man. My bad, I'll use a proper editor. Cheers
PLEASE post code using the "little running man" button. Your code as posted contains non-ASCII quotes and is therefore completely unusable.
As I see it, those non-standard quotes are the reason for your syntax ERROR.
STRONG HINT: never use word processors for programming, only suitable text editors like the SAS Enhanced Editor or notepad++.
This code works:
data _null_;
array alts[13] $12 _temporary_ ('Update' 'Notes' 'Comments' 'Wall posts' 'Private messages' 'Chat' 'Groups' 'Newsfeed' 'Like' 'Photos/Videos' 'Events' 'Gaming' 'Fan pages');
run;
Post code and log into a code box opened using the forum's {I} as below:
73 array alts[13] $12 _temporary_ (’Update’ ’Notes’ ’Comments’ ’Wall posts’ ’Private messages’ - 22 76 73 ! ’Chat’ ’Groups’ ’Newsfeed’ ’Like’ ’Photos/Videos’ ’Events’ ’Gaming’ ’Fan pages’); ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant, a datetime constant, a missing value, iterator, (. ERROR 76-322: Syntax error, statement will be ignored. 74 set sasuser.bibd; /* read design */ ERROR: File SASUSER.BIBD.DATA does not exist. 75 put alts[x1] +(-1) ’, ’ /* print each attr, comma separated */ - 22 200 76 alts[x2] +(-1) ’, ’ alts[x3] +(-1) ’, ’ alts[x4]; - - 22 22 200 200 ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, arrayname, #, (, +, /, //, ;, @, @@, OVERPRINT, _ALL_, _BLANKPAGE_, _ODS_, _PAGE_. ERROR 200-322: The symbol is not recognized and will be ignored. 77 run;
The message window reformats the code. With the above it is easy to see that the error is indicated by the _ character and is coming from the smart quote before Update. @RW9 is correct about the smart quote issue.
smart quote ’ program quote '
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.