Hi All,
I am working on SAS FM rules. I would like store a column name in a variable like below.
&rule.name = 'column_name';
This is because the column name gets updated every year. Instead of replacing the column name in the sas code, I would like to pass it a string. Eventually I will get this string (column name) from lookuplist.
Generally the code works like this.
if
column_name <= 350
then do;
I would like to change it to.
if
&rule.name <= 350
then do;
But I got an error that i am comparing the string to numeric, which is obvious. Please help me out with this automation.
Thank you
When you execute code with macro variables in it, the value of the macro variable is used in place of the macro variable, and this must create valid legal working SAS code.
So, when you run this line of code
if &rule.name <= 350 then do;
SAS really executes this:
if 'column_name' <= 350 then do;
Can you see why this is not a valid SAS statement that causes errors?
It will work if you remove the quotes, assuming COLUMN_NAME is really a numeric variable name that exists in the data set. Whether or not that is what you want is another issue.
First and foremost, keep in mind that the macro language is a text replacement tool for generating dynamic code. It has no "data types" except text, and does not need quotes, unless you want the quotes to be part of the text.
Hi Kurt,
Thanks for your reply and Happy New Year!
I am using lookup list to retrieve the string. As it is coming in the string format, it throwing an error. Please refer the below code and help me out.
&rule.name = '';
&rule.column_type = 'abc'; (This is the key field supplied to list contains)
if
%listcontains(lookuplist_name,&rule.column_type)
then do;
&rule.name = &listvalue.column_name;
end;
I am doing all of this in SASFM rules. Please help me out.
Thanks,
Sai Teja
Chartis names SAS a leader in both Model Risk Governance and Model Validation