Intern - How to compare two rates in SAS - Need Help, Please

Reply
Occasional Contributor
Posts: 11

Intern - How to compare two rates in SAS - Need Help, Please

Hi, I have a semester's worth of knowledge on SAS and picked up an internship at a state health department so my background in SAS needs a refresher. My first project is comparing the number of forms received this year (electronically received) to last years (received by mail). They would like for me to compare by week to week number of entries received for each year. The dates received have been put into excel by mm//dd/yyy. I have full flexibility for presentation so I was thinking of comparing the rates by numbers and visually with a histogram.

 

My question: How do I convert mm/dd/yyyy to a numerical variable and record the number of forms received weekly?

Super User
Posts: 19,157

Re: Intern - How to compare two rates in SAS - Need Help, Please

[ Edited ]

You can find a lot of SAS tutorials here

http://video.sas.com/#category/videos/how-to-tutorials

 

Is your data already in SAS? If so, run a proc contents and post that and hightlight which variables are the ones that you need help with. 

Otherwise first get your data into SAS using PROC IMPORT.

 


ogarduno wrote:

Hi, I have a semester's worth of knowledge on SAS and picked up an internship at a state health department so my background in SAS needs a refresher. My first project is comparing the number of forms received this year (electronically received) to last years (received by mail). They would like for me to compare by week to week number of entries received for each year. The dates received have been put into excel by mm//dd/yyy. I have full flexibility for presentation so I was thinking of comparing the rates by numbers and visually with a histogram.

 

My question: How do I convert mm/dd/yyyy to a numerical variable and record the number of forms received weekly?


 

Occasional Contributor
Posts: 11

Re: Intern - How to compare two rates in SAS - Need Help, Please

Thanks for the link! Definitely going to look in there. I think I figured out how to format my date correctly with:

 

data have;

informat date mmddyy10.;

format date mmddyy10.;

input date;

cards;

01/31/2012;

 

data want;

set have;

ndate=put(date,mmddyyn.);

proc print;run;

 

I think my question now is how can I create a visual aid for the number of entries by each week? My starting date is 06/01/2017 and I have to count the number of entries received by each week.

 

Super User
Posts: 19,157

Re: Intern - How to compare two rates in SAS - Need Help, Please

[ Edited ]

Use PROC FREQ with a format for your date.

You can find the correct formats here:

proc freq data=have;
table date/out=want;
format date weeku3.;
run;

 


ogarduno wrote:

Thanks for the link! Definitely going to look in there. I think I figured out how to format my date correctly with:

 

data have;

informat date mmddyy10.;

format date mmddyy10.;

input date;

cards;

01/31/2012;

 

data want;

set have;

ndate=put(date,mmddyyn.);

proc print;run;

 

I think my question now is how can I create a visual aid for the number of entries by each week? My starting date is 06/01/2017 and I have to count the number of entries received by each week.

 


 

Super User
Posts: 11,134

Re: Intern - How to compare two rates in SAS - Need Help, Please

I agree with @Reeza that a format is the most likely way to group date items though SAS has not supplied a format that would include Year information and week in a nice form. But they allow you to create a custom format, something you may not have been exposed to previously, that allows providing a more flexible appearance. Here is an example showing Year and week of year combined.

Proc format library=work;
picture Yearwk  (default=7)
low-high = '%Y-%0W' (datatype=Date);
run;

data example;
   input dd mmddyy10.;
datalines;
01/05/2017
10/06/2016
07/21/2015
;
run;

proc print data=example;
   format dd YearWk.;
run;

The - in the low-high = '%Y-%0W' (datatype=Date) is there as a visual separator, any character could be used. The 0 is to have single digit weeks prefixed with a 0 sort could be maintained as needed. Note that documentation for Proc Format includes other directives, the funny %Y and %W bits. The case of the letters is important so pay attention.

Ask a Question
Discussion stats
  • 4 replies
  • 253 views
  • 5 likes
  • 3 in conversation