Solved
Contributor
Posts: 36

# Confused: Why SAS fail to select a row by condition...

Hi I need some help to figure out this puzzle, I am QAing my own work, and found an error:

I have this dataset called , with a calculated column called 'week', which, from both proc freq and my eye ball checking, has values from 0 -41.But, I try to print out some extreme values, like 41, log keeps telling me 'no rows were selected'.....

proc freq data=numerator2_full;

tables week;

run;

I know this probably looks very stupid, but this has drive me crazy....

Accepted Solutions
Solution
‎11-01-2017 07:39 PM
Super User
Posts: 7,928

## Re: Confused: Why SAS fail to select a row by condition...

Perhaps it is not exactly 41?

``where round(week,1)=41 ;``

Or perhaps you have a format attached?

``````data want;
set have ;
if strip(vvalue(week))='41';
run;``````

All Replies
PROC Star
Posts: 8,142

## Re: Confused: Why SAS fail to select a row by condition...

Please post you full log, i.e., including the part where you ran the proc freq.

Art, CEO, AnalystFinder.com

Solution
‎11-01-2017 07:39 PM
Super User
Posts: 7,928

## Re: Confused: Why SAS fail to select a row by condition...

Perhaps it is not exactly 41?

``where round(week,1)=41 ;``

Or perhaps you have a format attached?

``````data want;
set have ;
if strip(vvalue(week))='41';
run;``````
Contributor
Posts: 36

## Re: Confused: Why SAS fail to select a row by condition...

good point @Tom, this week variable is calculated. I calculated as (Vaccine_Day - Pre_day)/7 = week format 8.0

Now I am curious to see how my

Super User
Posts: 23,224

## Re: Confused: Why SAS fail to select a row by condition...

Ah, yes, you definitely have decimal points then. If you want it actually rounded then round the value.

round((Vaccine_Day - Pre_day)/7, 1) format = 8.0

Super User
Posts: 23,224

## Re: Confused: Why SAS fail to select a row by condition...

Run a PROC CONTENTS on your dataset and check the format and type.

Frequent Contributor
Posts: 113

## Re: Confused: Why SAS fail to select a row by condition...

How did you calculate the variable WEEK?

Contributor
Posts: 36

## Re: Confused: Why SAS fail to select a row by condition...

I calculated as (Vaccine_Day - Pre_start_day)/7 = week format 8.0

week is supposed to be 'at which week at pregnant a lady got her vaccine'.

Super User
Posts: 7,928

## Re: Confused: Why SAS fail to select a row by condition...

LisaYIN9309 wrote:
I calculated as (Vaccine_Day - Pre_start_day)/7 = week format 8.0

week is supposed to be 'at which week at pregnant a lady got her vaccine'.

Attaching a format to a variable will change how the variable is printed, but it does not change the value. If you want WEEK to be an integer then use ROUND() or INT() function.

I am also curious as to why you picked 8.0 as the format to attach.  Did you really expect to have WEEK counts as high as 99 Million?

Frequent Contributor
Posts: 113

## Re: Confused: Why SAS fail to select a row by condition...

you can try using int(week)=41, that should help.

☑ This topic is solved.

Discussion stats
• 9 replies
• 157 views
• 4 likes
• 5 in conversation