BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mariamon0
Fluorite | Level 6

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 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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.

View solution in original post

6 REPLIES 6
PeterClemmensen
Tourmaline | Level 20

Can you post some sample of your data for us to work with?

 

Makes it much easier to provide a usable code answer

mariamon0
Fluorite | Level 6

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.

Astounding
PROC Star

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.

mariamon0
Fluorite | Level 6

But I want to know how many study ids have 10 valid step days...this doesnt produce what I need

Astounding
PROC Star

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.

mariamon0
Fluorite | Level 6

thanks for clearing that up! makes sense now!