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

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

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

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;

PG

View solution in original post

5 REPLIES 5
mkeintz
PROC Star

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'

 

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
PaulaC
Fluorite | Level 6
Yes, visit is a character variable. I strip(visit)="001.00" and I got a result but it did not seem to subset the data to give the counts with only one observation per patient. The number I got was much more than it should be. Thanks.
mkeintz
PROC Star

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.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
PGStats
Opal | Level 21

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;

PG
PaulaC
Fluorite | Level 6
Thank you for your suggestion. I will try that.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 3701 views
  • 0 likes
  • 3 in conversation