BookmarkSubscribeRSS Feed
nduksy
Obsidian | Level 7

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;

6 REPLIES 6
PaigeMiller
Diamond | Level 26

... 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).

--
Paige Miller
mkeintz
PROC Star

In short, saying "it doesn't work" doesn't work.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
nduksy
Obsidian | Level 7

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;

 

 

Reeza
Super User
You put the format in the VAR statement, it belongs in a FORMAT statement. They're entirely separate. The ATTRIB statement allows you to combine setting different attributes in a single statement if you want to do something like that. VAR statements control what variables are displayed in the PROC.
ballardw
Super User

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.

PGStats
Opal | Level 21

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;

PGStats_0-1611360813400.png

 

PG

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 6 replies
  • 1363 views
  • 6 likes
  • 6 in conversation