Hello,
I have a clinical trial dataset and am trying to determine the frequencies of a few categorical variables as well as the number of unique patients per study arm at baseline.
I had initially done proc freq, but since I have multiple rows for each patient due to multiple visits per patient I was told that for proc freq there should only be one row/person. So, the values I got were a count of the same patient numerous times. I was told that I could use the where statement to only get the frequency at the baseline visit, but that did not work either. No observations were read.
My code is below:
proc freq data=xxxxl;
where visit="001";
tables race*group sex*group /norow nopercent;
run;
I received the following message in the log: NOTE: No observations were selected from data set xxx.
NOTE: There were 0 observations read from the data set xxx.
WHERE visit='001'
I am not sure what I did wrong and what I need to do to get the correct answer.
I am expecting the output to look as follows:
Group 1 Group 2
xxx xxx (these numbers would the number of unique patients in each group)
Race Group 1 Group 2
White xxx xxx
Black xxx xxx
Other xxx xxx
Any help would be greatly appreciated.
Thanks
Assuming your data is sorted by some patient_Id variable, try keeping the first record for each patient:
data patients;
set xxxxl;
by patient_Id;
if first.patient_Id;
run;
proc freq data=patients;
tables race*group sex*group /norow nopercent;
run;
Visit is a character variable?
Then do a proc freq of visit to see what values it actually has in the data step.
And also note;
where visit='001' will NOT match a right-justified 4-byte visit value of ' 001' (note leading space). If that's the problem, then either
where visit=' 001'
or
where left(visit)='001'
If you get fewer "001.00" cases than expected, then perhaps the original visit coding has errors or incosistencies. I think you have to find a patient with no visit="001.00" to see whether there are other codes indicating baseline visit.
Assuming your data is sorted by some patient_Id variable, try keeping the first record for each patient:
data patients;
set xxxxl;
by patient_Id;
if first.patient_Id;
run;
proc freq data=patients;
tables race*group sex*group /norow nopercent;
run;
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.