Hi,
I am trying to include a numeric variable in an ODS text statement. Is there a way to do that?
The code is something like this:
ods text= "^S={just=l} Note: [xxx] subjects are missing data at this time."
I want to substitute the variable count in place of the Xs.
It is part of a macro code and hence do not want to hard code it.
Thanks,
Neha.
Create a macro variable that holds the value and then use it in the text.
proc sql noprint;
select count(*) into :n_count from have where missing(var);
quit;
ods text = "^S={just=l} Note: [&n_count.] subjects are missing data at this time."
Create a macro variable that holds the value and then use it in the text.
proc sql noprint;
select count(*) into :n_count from have where missing(var);
quit;
ods text = "^S={just=l} Note: [&n_count.] subjects are missing data at this time."
Proc sql creates the macro variable that contains the count. You can use a different method to create the macro variable.
The ODS text statement uses the macro variable.
I tried the code and its working, but I am getting parenthesis around the numbers which I don't want. Also, is it possible to get the numbers in words?
The brackets were in your ODS text statement. Remove them.
To get them as words use the WORDS. format.
proc sql noprint;
select put(count(*), words.) into :n_count from have where missing(var);
quit;
Perfect! Getting them in words now without the parenthesis, but the formatting isnt very accurate:
ten subjects not included
How do I get rid of the space and can I capitalize the first letter?
Also, the code does not output zero. Is there a way to fix this?
Quick and dirty:
%let n_count=0;
just before the SQL that does the count.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.