I want to pass the contents of an entire IN list. Each of the elements in the list have to be quoted. What I have is:
%LET INECCGRP = "('1-1' '1-3' '1-5' '1-7' '1-9' '1-11' '1-13' '1-15')";
As shown below, the macro variable INECCGRP resolves to: "('1-1' '1-3' '1-5' '1-7' '1-9' '1-11' '1-13' '1-15')"
including the leading and trailing double-quotation marks which make that invalid at execution.
I'm sure this is some combination of the xQUOTE functions but I'm not hitting the right ones in playing trial and error.
The users of this program will edit the %LET statements but not the underlying macro.
Any help is appreciated.
Error received:
44021 /* ----------------------------------------------------------------------------------------- ------------------- */
44022 /* Below: list the Parity Groups to be used for the Pool's P-Vols. Use single quote
44022! marks with a hyphen */
44023 /* Example: if ECC_Group in ('1-1' '1-3' '1-5' '1'7');
44023! */
44024 /*
44024! -----------------------------------------------------------------------------------------
44024! ------------------- */
44025
44026 DQINECC1 = length((%STR(&INECCGRP)));
SYMBOLGEN: Macro variable INECCGRP resolves to "('1-1' '1-3' '1-5' '1-7' 1-9' '1-11' '1-13'
'1-15')"
44027 DQINECC2 = substr(&INECCGRP,2,(DQINECC1-1)); put @ 001 "DQINECC2=" DQINECC2;
SYMBOLGEN: Macro variable INECCGRP resolves to "('1-1' '1-3' '1-5' '1-7' 1-9' '1-11' '1-13'
'1-15')"
44028
44029 if ECC_Group in DQINECC2;
ERROR: The right-hand operand must be an array name or a constant value list. The specified
name DQINECC2, is not an array.
44030
44031
44032
44033 /*('1-1' '1-2' '1-3' '1-4' '1-5' '1-6' '1-7' '1-8' '1-9' '1-10' '1-11' '1-12' '1-13'
44033! '1-14' '1-15') ; */
44034
Your actual error message is from the miss use of the IN operator in the SAS and not from the macro variable.
You have written: if ECC_GROUP in DQINECC2
You cannot use the IN operator with a single character variable. You need to use in in the form
if ECC_GROUP in ('1-1' '1-3' '1-5' '1-7' '1-9' '1-11' '1-13' '1-15') ...
You could use the macro variable but you would need to get rid of the unneeded extra double quote characters around the outside.
%LET INECCGRP = ('1-1' '1-3' '1-5' '1-7' '1-9' '1-11' '1-13' '1-15') ;
...
if ECC_Group in &ineccgrp ;
Why did you include the double quotes in the first place?
It wouldn't accept the value including the parenthesis without the double quotes
A programming style choice. I would tend not to disguise the purpose of the macro variable as a combination of parentheses and a value list.
%let INECCGRP = '1-1' '1-3' '1-5' '1-7' '1-9' '1-11' '1-13' '1-15';
and in the datastep
if ECC_group in (&ineccgrp);
then when I read the code much later I will realize the &inccgrp relates to a list of values. and that's all (hopefully).
What wouldn't accept them? The %LET statement doesn't care.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.