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

 

proc format;
value income_format
low -< 0 = "low"
1 -< 30 = "low-medium"
30 -< 60 = "average"
60 -< 90 = "high"
90 - high = "excellent";
run;



proc freq data = lib1.all;
format income income_format.; /* assign IncomeFmt format to Income variable */
tables income
/OUT = income_table outcum ;
run;

 

 

sasprogramming_0-1621736469184.png

 

The above code creates custom bins for certain level of incomes, I think create a table to put my data into the custom bins. This all works fine, however I wan't to be able to create the above frequency table by date, my data is monthly and I have a field called DATE. How do I achieve this? Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
sasprogramming
Quartz | Level 8

Found the solution thanks.

 

proc freq data = lib1.all;
format income income_format. DATE YYMMD7.;
by DATE; tables income /OUT = income outcum ; run;

Your answer was just missing specifying to use the `by` line.

 

View solution in original post

5 REPLIES 5
Tom
Super User Tom
Super User

Use any one of the date formats that only displays the year and month.  Like YYMMD.

https://documentation.sas.com/doc/en/vdmmlcdc/8.1/ds2pg/p0bz5detpfj01qn1kz2in7xymkdl.htm

sasprogramming
Quartz | Level 8
this doesn't answer my question??
mkeintz
PROC Star

@sasprogramming wrote:
this doesn't answer my question??

Try it, i.e. use YYMMD7. as the format in proc freq.

 

I think you'll see that it does answer your question.

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

--------------------------
sasprogramming
Quartz | Level 8

Found the solution thanks.

 

proc freq data = lib1.all;
format income income_format. DATE YYMMD7.;
by DATE; tables income /OUT = income outcum ; run;

Your answer was just missing specifying to use the `by` line.

 

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
  • 1809 views
  • 0 likes
  • 4 in conversation