Desktop productivity for business analysts and programmers

odd behavior for a string parameter

Reply
Frequent Contributor
Posts: 139

odd behavior for a string parameter

I discovered that by creating a string parameter in the Parameters (Macro Variables) Manager. SAS Enterprise Guide (4.1.0.471) wraps the value with unreadable characters © and ® respectively. Does any one else have this problem.


CODE:
** in the Parameter Manager make a parameter named X;
** set it to a string;
** add parameter in code module;


options symbolgen merror mologic;
proc sql;
create table shoes_&x as
select *
from sashelp.shoes
where stores=&x;

proc sql;
select *
from dictionary.macros;

** GLOBAL X 0 ©12® ;
** the macro var x resolves with unreadable characters;

LOG:
1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL=%NRBQUOTE(Code);
4 %LET _EGTASKLABEL=%NRBQUOTE(Code);
5 %LET _CLIENTPROJECTNAME=%NRBQUOTE();
6 %LET _SASPROGRAMFILE=;
7 %LET x = %NRSTR(12);
8
9 ODS _ALL_ CLOSE;
NOTE: Some of your options or statements may not be supported with the Activex or Java series
of devices. Graph defaults for these drivers may be different from other SAS/GRAPH
device drivers. For further information, please contact Technical Support.
10 OPTIONS DEV=ACTIVEX;
SYMBOLGEN: Macro variable SASWORKLOCATION resolves to "C:\DOCUME~1\ddputnam\LOCALS~1\Temp\SAS
Temporary Files\_TD1368\Prc2/"
11 FILENAME EGHTML TEMP;
NOTE: Writing HTML(EGHTML) Body file: EGHTML
12 ODS HTML(ID=EGHTML) FILE=EGHTML ENCODING='utf-8' STYLE=EGDefault
12 ! STYLESHEET=(URL="file:///C:/engapps/SAS/Shared%20Files/BIClientStyles/EGDefault.css")
12 ! ATTRIBUTES=("CODEBASE"="http://www2.sas.com/codebase/graph/v91/sasgraph.exe")
12 ! NOGTITLE NOGFOOTNOTE GPATH=&sasworklocation;
SYMBOLGEN: Macro variable SYSVLONG resolves to 9.01.01M3P020206
SYMBOLGEN: Macro variable GRAPHAVAIL resolves to 9.01 TS1M3
13
14 %gaccessible;
SYMBOLGEN: Macro variable ACCESSIBLE resolves to ACCESSIBLE
15 ** in the Parameter Manager make a parameter named X;
16 ** set it to a string;
17 ** add parameter in code module;
18 ** GLOBAL X 0 ©12® ;
19
ERROR 13-12: Unrecognized SAS option name, MOLOGIC.
20 options symbolgen merror mologic;
_______
13

21 proc sql;
22 create table shoes_&x as
SYMBOLGEN: Macro variable X resolves to 12
SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been
unquoted for printing.
22 create table shoes_&x as
__
202
ERROR 202-322: The option or parameter is not recognized and will be ignored.

NOTE: Line generated by the macro variable "X".
22 shoes_12
__
22
ERROR 22-322: Syntax error, expecting one of the following: (, '.', AS, LIKE.

2 The SAS System 13:58 Thursday, August 19, 2010

23 select *
24 from sashelp.shoes
25 where stores=&x;
SYMBOLGEN: Macro variable X resolves to 12
SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been
unquoted for printing.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
26
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds



27 proc sql;
28 select *
29 from dictionary.macros;
30
31
32 %LET _CLIENTTASKLABEL=;
33 %LET _EGTASKLABEL=;
34 %LET _CLIENTPROJECTNAME=;
35 %LET _SASPROGRAMFILE=;
36
37 ;*';*";*/;quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds


37 ! run;
38 ODS _ALL_ CLOSE;
39
40
41 QUIT; RUN;
42
SAS Super FREQ
Posts: 8,814

Re: odd behavior for a string parameter

Hi:
In most cases, those "unprintable" characters are removed appropriately, as needed in the code and you can see evidence of this in the SYMBOLGEN message:

SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing.


If you look in the documentation:
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#/documentation/cd...

You will discover that some macro values are protected with a "delta" character. The above page says:
beginquote

When the macro processor masks a text string, it masks special characters and mnemonics within the coding scheme, and prefixes and suffixes the string with a hexadecimal character, called a delta character. The prefix character marks the beginning of the string and also indicates what type of macro quoting is to be applied to the string. The suffix character marks the end of the string. The prefix and suffix characters preserve any leading and trailing blanks contained by the string. The hexadecimal characters used to mask special characters and mnemonics and the characters used for the prefix and suffix might vary and are not portable.

There are more hexadecimal combinations possible in each byte than are needed to represent the symbols on a keyboard. Therefore, when a macro quoting function recognizes an item to be masked, the macro processor uses a previously unused hexadecimal combination for the prefix and suffix characters.
endquote


And about THIS error mesage,
ERROR 202-322: The option or parameter is not recognized and will be ignored.

It is saying that there's something about
shoes_&x that it doesn't like (and you're right, it doesn't like those delta characters) But it is easy to get rid of them. Sometimes, you have to remove the special characters yourself.

You will find that exact error message (202-322) in this Tech Support note, AND the note shows how to use the %UNQUOTE function to properly remove the special characters:
http://support.sas.com/kb/17/444.html

Although the note talks mostly about user id and password and needing to unquote, it also shows how this example:
data my_&testvar;
needs to turn into this:
data my_%unquote(&testvar);

And in your case, that would be the equivalent of having
create table shoes_&x as
turn into
create table shoes_%unquote(&x) as

Hope this helps!
cynthia
Frequent Contributor
Posts: 139

Re: odd behavior for a string parameter

Cynthia
Thank you so much.
The %unquote function worked perfectly.

One more thing if I make the parameter X an integer I don't have this problem. In the future I'll use %unquote on my string parameters.

Thanks again.
Ask a Question
Discussion stats
  • 2 replies
  • 599 views
  • 0 likes
  • 2 in conversation