I have this macro variable:
82 %put &_fmm48.; "0.1283200146 * cdf('normal', temp(1), 46.076814239 , 1.4242197152 ) + 0.4126163318 * cdf('normal', temp(1), 37.291694824 , 4.5092171615 ) + 0.4590636536 * cdf('normal', temp(1), 22.406224725 , 7.4331299613 ) " 83 84 %studio_hide_wrapper;
And I want to use it in a resolve statement:
I post the line that works and the failing resolve intent with the error message:
if out_apzmto=48 then pred_cdf= 0.1283200146 * cdf('normal', temp(1), 46.076814239 , 1.4242197152 ) + 0.4126163318 * cdf('normal', temp(1), 37.291694824 , 4.5092171615 ) + 0.4590636536 * cdf('normal', temp(1), 22.406224725 , 7.4331299613 ); pred_cdf=resolve(&_fmm48.); NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column). 96:10 98:33 NOTE: Invalid numeric data, '.375327347 * cdf('normal', temp(1), 15.635497438 , 3.9918793772 ) + 0.3922306778 * cdf('normal', temp(1), 26.175544333 , 3.1090404865 ) + 0.1005071903 * cdf('normal', temp(1), 31.998863512 , 0.8964434876 ) + 0.0450229677 * cdf('normal', temp(1), 34 , 0.0001 ) + 0.0869118173 * cdf('normal', temp(1), 35.436121806 , 0.4959496162' , at line 96 column 10.
I'm not sure what you are trying to do, but if &_fmm48 has the value shown, you could simply do this in a DATA step (after removing the quotes from around the macro variable value, they don't belong there)
pred_cdf=&_fmm48;
Hi,
SAS calls removal of quotation marks dequoting. Unquoting has a different meaning in SAS. There is a DEQUOTE function, which can be called in the macro language via %SYSFUNC.
Try:
pred_cdf=%sysfunc(dequote(&_fmm48.)) ;
You shouldn't need the RESOLVE function for this example.
Often it is better to avoid adding quotation marks when you assign the value to your macro variable.
I'm not sure what you are trying to do, but if &_fmm48 has the value shown, you could simply do this in a DATA step (after removing the quotes from around the macro variable value, they don't belong there)
pred_cdf=&_fmm48;
So easy...
Is there a general rule when a macro variable shoud go within quotes?
I would say that you need quotes around macro variable values only in rare situations. I realize that isn't very helpful.
The answer certainly depends on how you will be using the macro variable after it is assigned the value. For simple text replacement in a DATA step, which is what you are doing here, quotes are just not needed. Please remember that macro variables are used for text replacement, so the macro variable as it appears in your code is replaced by the text of the macro variable value, and once this replacement happens, the resulting code must be legal valid SAS code that does what you want. If you have quotes around your macro variable value, then
pred_cdf=&_fmm48;
is actually
pred_cdf = "0.1283200146 * cdf('normal', temp(1), 46.076814239 , 1.4242197152 ) + 0.4126163318 * cdf('normal', temp(1), 37.291694824 ,
4.5092171615 ) + 0.4590636536 * cdf('normal', temp(1), 22.406224725 , 7.4331299613 ) ";
and this assigns a text string to pred_cdf, that's what the quotes indicate, that this is a text string, and so no math happens.
@acordes wrote:
So easy...
Is there a general rule when a macro variable shoud go within quotes?
That's an easy one. When you want the value of the macro variable to contain the quotes.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.