BookmarkSubscribeRSS Feed
DanD
Calcite | Level 5
I saw this in a piece of code - %let custsegs = %str('E|002878','E|010208','00002878','E|X02964','E|002964','CS|E|002878','CS|E|010208','OPT_FA|00002878','CS|E|X02964','CS|E|002964');

Can someone tell me what it means?

Thanks,

DanD
2 REPLIES 2
Cynthia_sas
Diamond | Level 26
Hi:
%STR is one of the SAS Macro Facility quoting functions. The relevant sections of the documentation are here:
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/tw3514-overvwqt.htm
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a001061325.htm
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a001072333.htm
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a001061345.htm

What will be informative, beyond the doc, is for you to find out WHERE in your code the macro variable &CUSTSEGS is used. For example, if you search for the macro variable in your code, you might find something like this:
[pre]
if WOMBAT in (&custsegs) then do;
... more code ...
[/pre]

which would tell you that the macro variable &CUSTSEGS is used in the IF statement to supply values for the IN operator that is testing the value of the dataset variable WOMBAT. If you then did a PROC FREQ:
[pre]
proc freq data=lib.dataset;
tables WOMBAT;
run;
[/pre]

you would find out whether the values of the WOMBAT variable were correctly specified in the %LET statement inside the %STR function.

Generally speaking any of the Macro Quoting Functions, including %STR are used to mask or hide the normal syntactic meaning of certain special characters, as defined in the documentation. In this instance, I suspect that %STR was used in the %LET statement because someone felt that the single quotes or the pipe symbols needed to be "protected".

cynthia
DanD
Calcite | Level 5
The variable isn't used anywhere in the code that I have. I only have part of the code.

Thanks for your reply.

DanD

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1270 views
  • 0 likes
  • 2 in conversation