Hi all-
I have an issue that has been confounding me to no end-
I have a query that goes like this-
PROC SQL;
SELECT sum(CASE WHEN COMPLIANT='NO' then 1 else 0 END),count(*)
into :NUM1, :NUM2
from XYZ
where put(FAC_ID,$shortfix.)='XXX'
/*group by FAC_ID*/
quit;
When I call the macro variables NUM1 and NUM2, NUM1 has a big trailing space-
I have attempted to modify it as putting it as a character variable to no avail.
NUM2 works just fine.
Any answers, solutions would be great.
Thanks
Lawrence
This should remove the spaces, I think....
%let num1=&num1;
%let num2=&num2;
%put NOTE: did it work **&num1** **&num2**;
This should remove the spaces, I think....
%let num1=&num1;
%let num2=&num2;
%put NOTE: did it work **&num1** **&num2**;
Thanks data_null_!
That helped!
Lawrence
hi ... you could also try ...
data x;
retain a b 5;
run;
proc sql noprint;
select a, b into :num1 separated by ' ', :num2 separated by ' ' from x ;
quit;
%put |&num1|&num2|;
|5|5|
from ...
http://www.sascommunity.org/wiki/Tips:Strip_Blanks_from_PROC_SQL-Created_Macro_Variable_Values
Or...
data x;
retain a b 555555555555;
format b best15.;
run;
proc sql noprint;
select a, b into :num1 trimmed, :num2 trimmed from x ;
quit;
%put |&num1|&num2|;
|5.556E11|555555555555|
PG
What version of SAS are you using? That doesn't work with my SAS 9.2.
Hi Data _null_,
It works with my SAS 9.3.
5
6 proc sql noprint;
7 select a, b into :num1 trimmed, :num2 trimmed from x ;
8 quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
9
10 %put |&num1|&num2|;
|5.556E11|555555555555|
You've already gotten solutions. This is just for insight ...
Macro variables hold character strings only. When SQL extracts a numeric value, and the into : operator requests that it be stored in a macro variable, SQL has to perform a numeric to character conversion. Off the top of my head it uses an 8-character width, rather than the 12-character width that CALL SYMPUT would use. However, unlike a DATA step, SQL doesn't give you a note that conversion is taking place. At any rate, the blanks you are witnessing are leading blanks (for both variables), rather than trailing blanks, produced by the conversion process.
Good luck.
Astounding-
Thanks for the tip. That helps.
Lawrence
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 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.