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?
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.
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.
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?
oh so true how would you take that into consideration in the code?
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;
The code above creates the month variable....if that's not enough, what do you mean?
sorry I didnt realize that was a function. the visit variable doesnt exist in my code
I just have admin_dt_1
Did you run the code, it only uses the date...
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....
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.