I am trying to determine how many "valid wear days" my participants have.
I have already determined a step valid to be more than 200 steps. stepvalid=1 vs. stepvalid=0
I want to know how many participants have 10 valid wear days 9 etc.
How would I code this?
I assume I use proc freq
Yes it does. Did you try it?
The report shows two key columns: per_study_ID and COUNT.
PER_STUDY_ID is the number of valid step days per Study ID.
COUNT is the number of Study IDs with that number of valid step days.
Can you post some sample of your data for us to work with?
Makes it much easier to provide a usable code answer
data stepdata3; set stepdata2;
format date mmddyy10. ped_date mmddyy10. match_date mmddyy10. baseline_day1 mmddyy10. baseline_day10 mmddyy10.;
ped_date = date;
if steps >31000 then steps = .;
if steps >= 200 then stepvalid = 1;
else if steps < 200 then stepvalid = 0;
else stepvalid = .;
match_date = ped_date;
run;
I want to know how many of my study_id's have 10 stepvalid days 9 stepvalid days etc.
A two-step counting process should make this easy:
proc freq data=have;
where stepvalid=1;
tables study_id / noprint out=counts (rename=(count=per_study_id) ) ;
run;
proc freq data=counts;
tables per_study_id;
run;
The first PROC FREQ saves the number of valid days for each Study ID. Then the second PROC FREQ uses those counts to produce the report.
But I want to know how many study ids have 10 valid step days...this doesnt produce what I need
Yes it does. Did you try it?
The report shows two key columns: per_study_ID and COUNT.
PER_STUDY_ID is the number of valid step days per Study ID.
COUNT is the number of Study IDs with that number of valid step days.
thanks for clearing that up! makes sense now!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.