06-04-2015 10:59 AM
I am trying to create a variable that is a 1 if it is in a range
My code looks like this:
if var1 in (41000:41099) then var2 = 1;
else var2 = 0;
It turns up with only 0's.
When I run this
proc freq data = new;
where var1 in (41000:41099);
It shows 50 numbers and hundreds of numbers in the freq. What am I doing wrong?
06-04-2015 12:22 PM
VAR1 must be an integer for IN(41000:41099) specification to match;
06-05-2015 12:14 PM
I think the problem you are experiencing is not in the code you are writing, which works just fine, but perhaps in the dataset you are reading in.
My hunch is that the user data _null_ could be right: make sure var1 in your dataset is actually a numeric variable.
Otherwise if you still have trouble, I'd suggest giving us a sample of the dataset you are reading in.
06-05-2015 01:18 PM
What is actually happening is further revealed in the SAS log when IN is used in a WHERE statement.