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

Hello, 

 

I am running a bunch of frequencies on outcomes by date, and I need the frequencies to appear by date in weeks instead of daily. I need the outcomes to appear with the week date labeled -- for example, "03/15/2020, Outcome X, Outcome Y. "03/22/2020, Outcome, X, Outcome Y', etc. I tried the "week" command (see below), but that just numbers the weeks and doesn't put them into an easy to read format.

data covidzip7; 
set covidzip6; 
rdate_wk = week(rdate, 'v'); 
format rdate_wk mmddyy10.; 
run; 

proc freq data = covidzip7; 
tables rdate_wk*race_new*agecat; 
run; 

 

Can anyone help? Thanks!  

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

I assume you want the first day of the week to be used (3/15/2020). This code will turn every date into the first day of the week, using the INTNX function.

 

data covidzip7; 
set covidzip6; 
rdate_wk = intnx('week',rdate,0,'b');
format rdate_wk mmddyy10.; 
run; 
proc freq data = covidzip7; 
tables rdate_wk*race_new*agecat; 
run; 

 

 

--
Paige Miller

View solution in original post

7 REPLIES 7
PaigeMiller
Diamond | Level 26

I assume you want the first day of the week to be used (3/15/2020). This code will turn every date into the first day of the week, using the INTNX function.

 

data covidzip7; 
set covidzip6; 
rdate_wk = intnx('week',rdate,0,'b');
format rdate_wk mmddyy10.; 
run; 
proc freq data = covidzip7; 
tables rdate_wk*race_new*agecat; 
run; 

 

 

--
Paige Miller
claremc
Obsidian | Level 7

This worked - thank you so much! 

MarySasbegginer
Calcite | Level 5
looking for help with my sas homework
really new to sas and coding
really need help
anyone?
Kurt_Bremser
Super User

Start a new thread of your own.

Describe your issue.

Post example data in usable form (data step with datalines, you can find thousands ofe xamples here on the communities).

Show expected results.

Most importantly, show what you have already tried so far. We are glad to assist when people run into problems, but we won't do others work for free.

 

If you need someone to do your work for you, hire a consultant.

MarySasbegginer
Calcite | Level 5

Hi Kurt, 

I don't want anyone to do my homework for me, why you assumed that?

But my problem is that we do 2 , 3 chapters a week and no matter how much i tried i always behind.

So in order to do my homework i need to understand how to do it which i don't yet hence asking for help.

 

Anyway thank you for you reply.

PaigeMiller
Diamond | Level 26

@MarySasbegginer 

 

Follow the advice given by @Kurt_Bremser and people will help you. He said:

 

Start a new thread of your own.

Describe your issue.

Post example data in usable form (data step with datalines, you can find thousands ofe xamples here on the communities).

Show expected results.

Most importantly, show what you have already tried so far.

--
Paige Miller

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
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
  • 7 replies
  • 854 views
  • 3 likes
  • 4 in conversation