BookmarkSubscribeRSS Feed
16 REPLIES 16
Reeza
Super User

How you do so depends on your current data structure.

 

What does the current data look like? Is there only one row per person? Anyone who visited 28days before September 1 is eligible and people who visit September 1 are eligible again on Sept 28 (or 29th)?

 

It helps if you can show your input data and for that small example the expected output. 

 


@xxartpopxx wrote:

I'm looking to create a table where each row in september has a date  to determine how many people are eligible for a visit. 

Someone is eligible for a visit after 28 days.

date='01SEPT2022'd;

visitdiff=date-dmin_dt_1;

diff=admin_dt_2-admin_dt_1;

where visitdiff>=28;

How do I create a table showing all 30 days in September and the number of people who are eligible for a visit?


 

ballardw
Super User

That is a pretty incomplete description. How do we know who is eligible and when? What variables?

 

Actual example data of what you have will get things going a lot quicker, especially  if the data is in the form of a working data step.

xxartpopxx
Fluorite | Level 6

sorry about that I tried to explain more in my post above. 

I am looking to create a  table showing dates sept 1st-30th and the number of eligible folks.

Everyone has a unique admin date 1.

Anyone who is eligible = admin date 1 was over 28 days ago.

I want to show how many eligible folks are there for each day of the month in September.

Reeza
Super User
data revisit_dates;
set request;
revisit_date = admin_dt_1 + 28;
month_revisit = month(revisit_date);
run;

proc freq data=revisit_dates;
where month_revisit=9;
table revisit_date;
run;

This does not handle if a person visits on September 1 and is eligible again on September 29th...is that something that needs to be considered?

xxartpopxx
Fluorite | Level 6

oh so true how would you take that into consideration in the code?

Reeza
Super User

Lazy way:

 

data revisit_dates;
set request;
do visit=1 to 3; *output next three visit dates;
revisit_date = admin_dt_1 + 28;
month_revisit = month(revisit_date);
output;
end;
run;

proc freq data=revisit_dates;
where month_revisit=9;
table revisit_date;
run;
xxartpopxx
Fluorite | Level 6
there is no month variable how would I create one?
Reeza
Super User

The code above creates the month variable....if that's not enough, what do you mean?

xxartpopxx
Fluorite | Level 6

sorry I didnt realize that was a function. the visit variable doesnt exist in my code

I just have admin_dt_1 

Reeza
Super User

Did you run the code, it only uses the date...

xxartpopxx
Fluorite | Level 6

data dose2eligible;

set request;

do visit=1 to 3;

  revisit_date=admin_dt_1+28; /*eligible date for 2nd dose*/

month_revisit=month(revisit_date); /*month of revisiting*/

if revisit_date>=28 then eligible=1; else if revisit_date<28 then eligible=0; /*eligible for a vaccine 2nd dose*/

    output;

  end;

 

  format

    date month_revisit revisit_date date9.;

run;

/*determine amount eligible*/

proc freq data=dose2eligible; where month_revisit=9  ;  table revisit_date ;  run;

I need the revisit date to equal + or = to 28 days how do I show that? it also is still only showing 28 days in september....

Reeza
Super User

I need the revisit date to equal + or = to 28 days how do I show that? it also is still only showing 28 days in september....

 

I don't know what that means. The revisit data set has the dates when the person is eligible for the next three visits (identified by visit). 

You likely have some days where there were no visits (weekends) so you'll need to add those dates in as zeros which is doable.

I go back to my first response - please show a sample of your data and what you want as output. 

 

 

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
  • 16 replies
  • 1264 views
  • 0 likes
  • 3 in conversation