turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- Counting the number of patients and frequencies fo...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-02-2016 12:55 PM

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

Accepted Solutions

Solution

12-09-2016
04:22 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-03-2016 12:14 AM - edited 12-03-2016 12:14 AM

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

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-02-2016 01:01 PM

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'

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-02-2016 02:45 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-02-2016 03:01 PM

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.

Solution

12-09-2016
04:22 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-03-2016 12:14 AM - edited 12-03-2016 12:14 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-09-2016 04:21 PM

Thank you for your suggestion. I will try that.