Hello All,
I am new to SAS I am trying to display the dollar sign for the 'sales' variable in the report when it prints.
I have tried doing this:
var Sales dollar10.2 Inventory Returns
but it doesn't work.
Any help will be appreciated. See my code below
/*******************************************************************
data derive.shoes_stats;
set shoes_stats;
run;
proc sort data = derive.shoes_stats;
by region;
run;
ods rtf file='C:\Users\18483\Documents\SAS Training\Studies\Clinical\Data\output\shoes_region.rtf';
title 'Table 1: Summary Statistics of Shoes By Region';
proc means data = derive.shoes_stats;
class region;
var Sales Inventory Returns;
run;
ods rtf close;
... but it doesn't work
I realize you are new, so this ought to help you get faster responses in the future. Saying it doesn't work, but not giving us any additional information, will always result in a follow up question. We can't know what happened or why it doesn't work if that's all you tell us.
So, when something doesn't work, save yourself some time and please show us the incorrect output AND/OR the LOG from SAS AND/OR an explanation of what did happen and why it way wrong. If you are going to show us the LOG, please copy it as text and paste it into the window that appears when you click on the </> icon, this will format the LOG properly and make it more readable (and I don't try to read improperly formatted LOGs any more).
In short, saying "it doesn't work" doesn't work.
Thanks for the heads up. My code runs without errors and outputs the expected results to the .rtf file, but when I add this line: var Sales dollar10.2 Inventory Returns;
I get the error below and a blank .rtf file
5887 ods rtf file='C:\Users\18483\Documents\SAS Training\Studies\Clinical\Data\output\shoes_region.rtf'; NOTE: Writing RTF Body file: C:\Users\18483\Documents\SAS Training\Studies\Clinical\Data\output\shoes_region.rtf 5888 title 'Table 1: Summary Statistics of Shoes By Region'; 5889 proc means data = derive.shoes_stats; 5890 class region; 5891 var Sales dollar10.2 Inventory Returns; ---------- 22 201 ERROR 22-322: Syntax error, expecting one of the following: a name, ;, -, /, :, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_. ERROR 201-322: The option is not recognized and will be ignored. 5892 run;
I don't see where you attempt to use the format.
Proc Means does not format statistics. And since one of the default statistics is N it would not make sense to have $35 for the N of Sales.
So either use proc means to create a data set and then apply the formats to appropriate variables with proc print or use a different procedure like proc report or proc tabulate where you can specify the format with the specific statistic as needed.
Something like:
proc means data = derive.shoes_stats noprint nway; class region; var Sales Inventory Returns; output out=work.summary (drop=_:) n= min= mean= max= std= /autoname ; run; Proc print data=work.summary noobs; var Sales_n Sales_min Sales_mean Sales_max; format Sales_min Sales_mean Sales_max Dollar10.2; run;
one way. Others depending on what the result really needs to look like.
I would suggest using option stackods. Example :
proc means data=sashelp.shoes stackods;
class region;
var sales;
ods output summary=sumry;
run;
ods rtf file="/home/pg/SASforum/rtgtest.rtf" style=journal;
proc print data=sumry;
format n 5.0 mean min max dollar11.2;
var n min mean max;
id region;
run;
ods rtf close;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.