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.

 

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!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 596 views
  • 0 likes
  • 4 in conversation