BookmarkSubscribeRSS Feed
nab102
Fluorite | Level 6

Hi  I'm new to SAS programming,

I want to count the total number of people in each year without double counting and using these conditions. This is the dataset

 

data.PNG

 

 

 

 For each patient I want to know ,if they got a vaccine (i.e. there is no missing value for the "total number of vaccines" column.

If the answer is "yes" to having a vaccine (that is for the patient , the "total of vaccine" column is not empty). Then do

 

1. Did you complete the vaccine (i.e. completed =1), if yes I want to count in the first year we see the patient ID. For example, customer ID K001, I will only count you once, that is  as a part of Year 2018 and not count in the any year you might appear. For example patient with ID K001 will only be counted in 2018 and not 2019 or any other year. and K003 will be counted in Year 2020 and NOT 2021 or any other year

 

2. if No to completion of vaccination (that is completed=0), I can you count you also in the first year you appeared in the dataset and can NOT for any other year. So, for example patient with ID K004 will be counted in year 2017.

I want to do this for each patient.

 

This is what I want .In 2017, we had a total of 2 patients because K004 and K007 are the only ones in that year. Year 2018, has a total of 2 people because K001 first year of vaccine 2018 so I counted it just once (and never in 2019) and patient with ID K005 are that year group.

 

want.PNG

 

Thank you. Please let know if you have questions

 

 

2 REPLIES 2
Reeza
Super User

Please post your data as text not images. Please also include a case where the first year vaccine is 0 and then a later is 1 and illustrate how that situation is handled. 

nab102
Fluorite | Level 6

Thanks Reza. I have attached the data in a text file. 

About the second question, there is no first vaccine is 0. You always have either a first vaccine or missing values.

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
  • 2 replies
  • 274 views
  • 0 likes
  • 2 in conversation