Date: Fri, 27 Feb 2004 14:12:30 -0800
Reply-To: "Tarbash Patel a.k.a. Babu" <epidemiologist@SCIENTIST.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Tarbash Patel a.k.a. Babu" <epidemiologist@SCIENTIST.COM>
Organization: http://groups.google.com
Subject: Re: Range checking question
Content-Type: text/plain; charset=ISO-8859-1
Try this...
/* Formats to Identify Out-of-Range Values */
proc format;
value $chkA 01 - 99 = " "
OTHER = "INVALID";
value $chkB A - C = " "
OTHER = "INVALID";
run;
/* Your Dataset */
data test;
input RAN004 $;
cards;
01C
04C
01B
01F
03C
02B
03B
02C
01C
02C
01C
03H
04C
05C
01C
04C
05G
07C
09C
08C
06C
01B
03D
02C
02B
04K
01C
02C
05B
03B
;
run;
data OutOfRange;
set test;
if put(substr(RAN004,1,2),$chkA.) ne "INVALID"
and put(substr(RAN004,3,1),$chkB.) ne "INVALID" then delete;
run;
proc print data=OutOfRange;
title "Out of Range Values";
title2 "By Suganshu Jain";
run;
------------------------------------
OUTPUT:
Obs RAN004
1 01F
2 03H
3 05G
4 03D
5 04K
mixiao@ucla.edu (miranda) wrote in message news:<eff27ff0.0402261530.2cd88e2d@posting.google.com>...
> Hi,
> I have a data field RAN004 valuse like nelow :
>
> RAN004
>
> 01C
> 04C
> 01B
> 01F
> 03C
> 02B
> 03B
> 02C
> 01C
> 02C
> 01C
> 03H
> 04C
> 05C
> 01C
> 04C
> 05G
> 07C
> 09C
> 08C
> 06C
> 01B
> 03D
> 02C
> 02B
> 04K
> 01c
> 02c
> 05B
> 03B
>
> The range of this field is 01A~99C,
> How could I check this field and report those out of range value like
> 01F,03H,05G,03D,04K ?
>
> Thanks.
|