| Date: | Fri, 16 Jan 2004 16:07:46 -0500 |
| Reply-To: | Howard Schreier <Howard_Schreier@ITA.DOC.GOV> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Howard Schreier <Howard_Schreier@ITA.DOC.GOV> |
| Subject: | Re: Table Lookup Question |
|
I imagine the problem is solved by now, but I'm still a bit mystified by
what you said about user-defined informats being only usable against "raw"
data. Consider:
data notraw;
do Userid = 'TOPCAT', 'TOPRAT', 'TOPDOG'; output; end;
run;
Proc FORMAT;
InValue $MLimit 'TOPCAT' = 1000
'TOPDOG' = 2000
'TOPRAT' = 3000 ;
Run ;
data _null_;
set notraw;
QUOTA = Input(Upcase(Userid),$Mlimit.);
put Userid= QUOTA=;
run;
Result:
Userid=TOPCAT QUOTA=1000
Userid=TOPRAT QUOTA=3000
Userid=TOPDOG QUOTA=2000
On Tue, 6 Jan 2004 17:27:36 -0500, Gerry <GPauline@FSMAIL.PACE.EDU> wrote:
>SAS-Pros:
>
>I apologize for the verbose question --
>
>I have data that I need to use for a data lookup. The values are USERID, a
>character variable (max of 30 chars in length) and QUOTA, a numeric value,
a
>minimum of 1000 (max is 9999). The values would look like:
>
>TOPCAT 1000
>TOPDOG 1000
>TOPRAT 1000
>
>I want to use the key value, USERID to retrieve the quota value, preferably
>as a numeric. I created a format table, using VALUE and treated the QUOTA
>value as a character:
>
>Proc FORMAT Library=QUOTA ;
> Value $MLimit 'TOPCAT' = '1000'
> 'TOPDOG' = '1000'
> 'TOPRAT' = '1000' ;
>Run ;
>
>For this application, the format table will be created each time the report
>program is run. I need to use QUOTA in the main program as a numeric (to
see
>if a user's assigned quota value is exceeded).
>
>This requires using:
>
>QUOTA = Input(Put(Upcase(Userid),$Mlimit.), 4.) ;
>
>This value would later be used in the program like this:
>
>If (MCount > QUOTA) Then ...
>
>The INVALUE option on PROC FORMAT allows for a format like MLimit to be
>created as a numeric, but seems to only be used for "on-the-fly" conversion
>of raw data (my data, both client and lookup, is coming from SQL Server
>using LIBNAME access).
>
>Given the power and flexibility of PROC FORMAT, I'm sure I'm either over
>looking the obvious or missing something rather blatant. Is there a better
>way to do this in PROC FORMAT, or perhaps should I switch to a binary
search
>/ array lookup ?
>
>The lookup table is not large, approximately 4000 members. This is being
run
>using SAS v8.2 on a W2K server.
>
>Any and all suggestions will be gratefully appreciated !
>
>Thank You.
>
>-Gerry
>
>Gerard T. Pauline
>Mgr, Internet Applications &
>University WebMaster
>Computer Systems, DoIT
>Pace University
|