LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (September 2006, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 1 Sep 2006 14:13:53 -0400
Reply-To:     Dianne Rhodes <diannerhodes@COMCAST.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Dianne Rhodes <diannerhodes@COMCAST.NET>
Subject:      format from cntlin dataset

One of my colleagues is developing code to create a format for all of the valid values on the mainframe, and assign it a numeric key, starting with one. To eliminate noise, she wants to get rid of everything that doesn't match her format. She wrote this code, but the results were not as expected. We expected one good value and one bad value, but instead both values passed the format. Take a look. I know its Friday and you were looking for OT Friday humor, but I think its important to be aware of this problem.

Here's the code - you can run it yourself. Version 9.1.3 I've solved the problem and when you all finish wrassling with it I'll explain.

data item_code_sid_map; length mf_item_code $13. item_sid 8; mf_item_code = '1311--AD13I01'; item_sid = 1; run;

DATA ITEM_REF ; SET item_code_sid_map; LENGTH start end $13 ; fmtname='ITEMS'; type='C'; start=mf_item_code; end=start; label=item_sid; RUN;

PROC format cntlin=ITEM_REF; RUN;

data item; length item_code $13. ; item_code = '1311--AC13I99'; output; item_code = '1311--AD13I01'; output; run;

data item_w_sid item_err; set item; item_sid = input(put(item_code, $items.),best.) ; if missing(item_sid) then output item_err; else output item_w_sid; run;

proc print data=item_w_sid; run;

and Here's the results... 27 28 data item_w_sid item_err; 29 set item; 30 item_sid = input(put(item_code, $items.),best.) ; 31 if missing(item_sid) then 32 output item_err; 33 else 34 output item_w_sid; 35 run;

NOTE: There were 2 observations read from the data set WORK.ITEM. NOTE: The data set WORK.ITEM_W_SID has 2 observations and 2 variables. NOTE: The data set WORK.ITEM_ERR has 0 observations and 2 variables. NOTE: DATA statement used (Total process time): real time 0.09 seconds cpu time 0.00 seconds

Thanks!

Dianne Rhodes @ bls


Back to: Top of message | Previous page | Main SAS-L page