Hi all,
I want to do a summary statistic, I want to have a dollar format but when I code, it does not work properly. My code is:
proc means data= merge_treat_con n nmiss mean median std min max ;
var TOT_ASS;
format tot_ass dollar10.2;
run;
The result is
What I want is the below display:
N: 315,644
Mean:$1,644,563.48
Median:$151,294.00
Minimum:$0
Maximum: $781,818,000
While I try the code below, it announces errors
proc means data= merge_treat_con n nmiss mean median std min max;
var TOT_ASS;
format tot_ass dollar10.2 N comma7. Mean median dollar10.2
minimum maximum dollar11.2;
run;
The log is
34 proc means data= merge_treat_con n nmiss mean median std min max ;
35 var TOT_ASS;
36 format tot_ass dollar10.2 N comma7. Mean median dollar10.2
WARNING: Variable N not found in data set WORK.MERGE_TREAT_CON.
37 minimum maximum dollar11.2;
WARNING: Variable MEAN not found in data set WORK.MERGE_TREAT_CON.
WARNING: Variable MEDIAN not found in data set WORK.MERGE_TREAT_CON.
WARNING: Variable MINIMUM not found in data set WORK.MERGE_TREAT_CON.
WARNING: Variable MAXIMUM not found in data set WORK.MERGE_TREAT_CON.
38 run;
Can you please help me to sort it out?
Thank you!
The format-statement has no effect on the variables created by proc means.
Run next code and add any reporting step or procedure:
proc means data= sashelp.class noprint
n nmiss mean median std min max ;
var height;
output out=temp (keep=_STAT_ height);
run;
proc transpose data=temp out=tmp1;
var height;
ID _stat_;
run;
The reason the FORMAT statement has no effect: PROC MEANS is not printing TOT_ASS. Instead, it is printing values that were calculated from TOT_ASS.
Luckily, several procedures are capable of printing summary statistics. For example, PROC TABULATE can do that, and it is much more capable when it comes to formatting. For example, here is some untested code that you can play with:
proc tabulate data=have noseps;
var tot_ass;
tables n='N:' * F=comma7.
mean='Mean:' * f=dollar15.2
median='Median:' * f = dollar15.2
min='Minimum:' * f=dollar15.2
max='Maximum:' * f=dollar15.2
,
tot_ass;
run;
You may need to play around with the table (such as adjusting the formats, or removing the NOSEPS option) to improve its appearance.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: