Task:
Using the two datasets below (partial data shown), write SAS syntax that would answer the following question: What proportion of close contacts were tested in the 5-10 day window of their quarantine period? Include documentation throughout your code. Comment on any assumptions you make or questions you would ask if you had the opportunity to iterate on this task. Include syntax that would create output suitable to answer this question.
Task:
Using the two datasets below (partial data shown), write SAS syntax that would answer the following question: What proportion of close contacts were tested in the 5-10 day window of their quarantine period? Include documentation throughout your code. Comment on any assumptions you make or questions you would ask if you had the opportunity to iterate on this task. Include syntax that would create output suitable to answer this question.
Many users here don't want to download DOCX files because of virus potential, others have such things blocked by security software or organization policy. Also if you give us DOCX we have to create a SAS data set and due to the non-existent constraints the result we end up with may not have variables of the same type (numeric or character) and even values.
Data should be in form of a data step (good learning point right there). The show what you have attempted and describe why it didn't work.
Since you have a question involving time interval this also might be of use: https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/... has a PDF with much information about dates.
If it was me, I would make 2 new variables, day5 and day10. I would make them like this: day5 = exp_date + 5 and day10=exp_date + 10. Then you need to merge the datasets by person ID. Then you can make a boolean variable like this:
flag = day5 <= test_date <= day10. This will assign flag to 1 if the conditions are true and 0 if false. If the combined dataset is not 1 row per person, then you will need to collapse it down to 1 row per person. Once you have a person-level dataset, then you can do proc freq on the flag variable to get the proportion.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.