Hi Guru's
my first question:
I have a numeric field formatted as dollar. But i want to have 'N/A' for where we have 0 value. How do i achieve this?
1) will i be able to keep dollar sign and format but still be able to put 'N/A' for 0's? good to have.
if var_a = 0 then var_a = 'N/A'; This is not working.
my second question:
When i use Proc report it gives me a good formatted/tabulated report, if i export to html the layout is all messed up.
basically i want to use the proc report output to export to any format (basically read-only) example pdf. How do i change the report layout to landscape (have 60 variables) and define field length etc.?
Thank you for sharing your experience/knowledge.
Raj
You could define a new format to force the zeros to N/A.
proc format ;
value nadollar (default=12) 0='N/A' other=[dollar12.] ;
run;
data _null_;
do i=0,500,1500,150000 ;
put i= nadollar8. ;
end;
run;
i=N/A
i=$500
i=$1,500
i=$150,000
Tom,
Thanks for the quick response.
I tried the above suggestion and may be i am doing something wrong.
Below is what i want to achieve.
data test1;
format xa $4.;
format ya dollar10.2;
format za dollar10.2;
input xa ya za;
cards;
3.1 1234 26459
3.1 3126 0
4.1 1235 0
4.1 0 6286
;
run;
data test2;
set test1;
if xa = '4.1' then ya = 'N/A';
if xa = '3.1' then za = 'N/A';
run;
Thanks again
I am not sure what you are trying to do with the second data step. Looks like if the value of XA is 4.1 then variable YA is not applicable? If so then does that mean that the value 0 for variable ZA in the third row is a real value of zero?
Have you considered using SAS missing values instead of coding the missing values as zeros? This will work much better if you want take the mean of values. The missing value will not count into the denominator. So the mean of (0,10) is 5 with a count of 2 but the mean of (.,10) is 10 with a count of 1. To do that make these changes to your sample program.
proc format ;
value nadollar .=' N/A' other=[dollar10.2] ;
run;
data test1;
length xa $4;
format ya za nadollar10.2;
input xa ya za;
if xa='3.1' then za=.;
if xa='4.1' then ya=.;
cards;
3.1 1234 26459
3.1 3126 0
4.1 1235 0
4.1 0 6286
;
run;
proc print;
run;
Obs xa ya za
1 3.1 $1,234.00 N/A
2 3.1 $3,126.00 N/A
3 4.1 N/A $0.00
4 4.1 N/A $6,286.00
Check out SAS missing values. They represent a concept of "this isn't a number".
Change Tom's format to:
proc format ;
value nadollar (default=12) .='N/A' other=[dollar12.] ;
run;
And your code becomes:
if xa = '4.1' then ya = .;
if xa = '3.1' then za = .;
Your output controls are basically going to be using ODS.
ODS HTML path="C:\your folders here" (url=none) body="your file name.html";
(and other html options are available)
<Your proc report code goes here>
ods html close;
Similar for PDF or RTF file formats using ODS PDF or ODS RTF or ODS TAGSETS.RTF ;
Do you have "Create HTML" turned on? That would allow the easiest way to get HTML output.
Hello Ballardw;
Thanks for the response.
I got the PDF and/or HTML output, but can i format the output to say landscape, fit to page1 and column width?
Where and how do i define the layout.
Thanks again
Raj
try adding:
options orientation=landscape;
Unlike PDF, HTML does not think of pages in terms of paper. Most of the formatting of the layout for HTML is done at the browser end, so there is less that you can control on the report generation side.
My question is answered.
Unfortunately I am not able to flag as "Correct Answer". Not sure why.
I will try back later for flag.
Thanks again.
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: