BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tri_Luong
Obsidian | Level 7

Hi everyone,

 

I am trying to use the scripts below:

 

 

proc freq data=work.loan_overdue;
     tables report_date/nopercent nocum frmat=comma16.0;
     weight 'total_amount';
run;

 

however, the results showed that:

 

REPORT DATE        Freq

01/08/2018              5.702E10              

02/08/2018              5.881E10

03/08/2018              6.378E10

04/08/2018              6.198E10

05/08/2018              5.979E10

 

Could you please help to instruct me how to:

 

1. show the format of Freq in "#,###.##" (for eg. 15,244,463,123.12)?

 

2. show the Freq with unit Million. (for eg. 15,244.46)?

 

Thank everyone.

It is never late for learning.
1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

The most flexible way would be to create an output data set instead of a report.  For example, change the TABLE statement to:

 

tables report_date / noprint out=want (keep=report_date count);

 

That gives you a data set named WANT with the variables REPORT_DATE and COUNT.  You could easily use that in a DATA step, and divide the COUNT values by 1,000,000 before printing.  And you could easily apply a format for printing COUNT.

View solution in original post

5 REPLIES 5
Astounding
PROC Star

The most flexible way would be to create an output data set instead of a report.  For example, change the TABLE statement to:

 

tables report_date / noprint out=want (keep=report_date count);

 

That gives you a data set named WANT with the variables REPORT_DATE and COUNT.  You could easily use that in a DATA step, and divide the COUNT values by 1,000,000 before printing.  And you could easily apply a format for printing COUNT.

Tri_Luong
Obsidian | Level 7

Thank Astounding for your prompt feedback. However, is there any way to change the format directly on the report instead of creating new data set?

It is never late for learning.
Astounding
PROC Star

I suppose you could always diivide your weight values by 1,000,000 before running PROC FREQ.

Tri_Luong
Obsidian | Level 7

Hi Astounding,

 

Did you mention that I should create one more variable which is "new value" = "original_value"/1,000,000 before proc freq with weight for "new value"? If I don't want to create new variable, what should I do?!

It is never late for learning.
Astounding
PROC Star

You could create it within a view, and make the view temporary.  For example:

 

data temp / view=temp;

set work.loan_overdue;

total_amount = total_amount / 1000000;

run;

 

Then use the view in PROC FREQ:

 

proc freq data=temp;

 

The rest stays the same, and the VIEW is temporary, stored in the WORK area.  It doesn't save a copy of your data, just a set of instructions for how to process the data.

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1214 views
  • 1 like
  • 2 in conversation