Hi ,
I have the following dataset and trying to add blank spaces with nbspace function, but appears as text in output of proc report.
I am not sure where I am getting wrong.
data test;
infile cards;
input x $ x1 $;
cards;
10.1 0
0 10.2
4.5 0
;
run;
ods escapecahr="$";
data test2;
array arr1(2) $15 x x1;
set test;
do i= 1 to 2;
if arr1(i)=0 then arr1(i)="0${nbspace3}";
end;
run;
ods rtf file="C:\test.rtf";
proc report data=test2;
column x x1;
define x/display center;
define x1/display center;
run;
ods rtf close;
proc report output is as below:
x x1
10.1 0{nbspace3}
0{nbspace3} 10.2
4.5 0{nbspace3}
Appreciate your input.
Thanks
Are you doing this to try to right justify or left justify the zeros? There are other ways to do this, and you'd be much better off if you read in X and X1 as numbers instead of characters. And I'm not sure exactly what nbspace at the end of the line will do anyway, usually you would use nbspace in the middle of text, such as this:
footnote "Marketing Data ^{nbspace 50} www.sas.com ";
Anyway, this line will not work
if arr1(i)=0 then arr1(i)="0${nbspace3}";
It should say
if arr1(i)="0" then arr1(i)="0${nbspace3}";
You can use the hard space character denoted in hex form as 'A0'x
if arr1(i)=0 then arr1(i)=cats('0', repeat('A0'x,2));
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.