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

I used code to develop a table that essentially tallies the number the count of people in an area in a given hour. I would like the divide the Day of the Week number columns in the table by an arbitrary number. For example, I would like to divide each individual cell (12am to 11pm) in Day of the Week column 1 by 5 (so 140/5, 141/5, 122/5 etc.); for Day of the Week column 2, I would like do to the same to each hour cell but by 4 instead of 5. Is the possible?

 

 

 

Capture.PNG

 

data ED_TAT2;
   set ED_TAT1;
   counttime = round(checkin_date_time,3600);
   format counttime datetime18.;
   do while (counttime le round(dispo_date_time,3600) );
      hr = timepart(counttime);
      day = weekday(datepart(counttime));
	  date = datepart(counttime);
      output;
      counttime= intnx('hour',counttime,1,'B');
   end;
run;

proc tabulate data=ED_TAT2;
   class hr day;
   format hr timeampm5. ;
   table hr='', day*n='' / box=hr;
   label hr='Hour'
         day= 'Day of week';
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Something like ths perhaps?

 

data ED_TAT2;
   set ED_TAT1;
   counttime = round(checkin_date_time,3600);
   format counttime datetime18.;
   do while (counttime le round(dispo_date_time,3600) );
      hr = timepart(counttime);
      day = weekday(datepart(counttime));
	  date = datepart(counttime);
      weight = 1/choosen(day, 5, 4, 3, 2, 1, 1, 1);
      output;
      counttime= intnx('hour',counttime,1,'B');
   end;
run;

proc tabulate data=ED_TAT2;
   class hr day;
   var weight;
   format hr timeampm5. ;
   table hr='', day*sum=''*weight='' / box=hr;
   label hr='Hour'
         day= 'Day of week';
run;
PG

View solution in original post

3 REPLIES 3
PGStats
Opal | Level 21

Something like ths perhaps?

 

data ED_TAT2;
   set ED_TAT1;
   counttime = round(checkin_date_time,3600);
   format counttime datetime18.;
   do while (counttime le round(dispo_date_time,3600) );
      hr = timepart(counttime);
      day = weekday(datepart(counttime));
	  date = datepart(counttime);
      weight = 1/choosen(day, 5, 4, 3, 2, 1, 1, 1);
      output;
      counttime= intnx('hour',counttime,1,'B');
   end;
run;

proc tabulate data=ED_TAT2;
   class hr day;
   var weight;
   format hr timeampm5. ;
   table hr='', day*sum=''*weight='' / box=hr;
   label hr='Hour'
         day= 'Day of week';
run;
PG
gbond21
Obsidian | Level 7

Amazing, works perfectly!

 

Somewhat new to SAS, are you aware a good resource where I can learn how your answer works, for example-I want to figure out how ' weight = 1/choosen(day, 5, 4, 4, 4, 4, 5, 5)' and 'days*sum=''*weight=''' work their magic.