LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (April 1996, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 3 Apr 1996 09:25:57 EDT
Reply-To:     whitloi1@WESTATPO.WESTAT.COM
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Ian Whitlock <whitloi1@WESTATPO.WESTAT.COM>
Subject:      Re[2]: SASTip: Disassociating format from a variable
Comments: To: Mike Sommers <MSOMMERS@CI.MADISON.WI.US>

Subject: Re: SASTip: Disassociating format from a variable Summary: An answer is given to the question - What should one do when codes change meaning? Respondent: Ian Whitlock <whitloi1@westat.com>

Mike Sommers <MSOMMERS@CI.MADISON.WI.US> posed a common and interesting problem which I do not think has yet been adequately addressed. He has a variable ACCDTYPE (accident type) with integer code values that changed meaning in 1994. For example, the old code 8 for accidents involving pedestrians was changed to 5. Although he doesn't explicitly say it, there is probably a new 8 with a totally different meaning.

In general he wants to know how to produce reports with the appropriate words instead of codes. The problem here is that ACCDTYPE is not really a variable in the data base sense that one value has a given meaning for the entire column. Given an 8 you do not know what type of accident it refers to until you also know the year of the accident since 8 has multiple meanings.

To solve the problem one must first obtain a variable with constant meaning. Let's assume that all codes are one or two digits. Then

if year ( accddate ) <= 1993 then accdtype = 100 + accdtype ; else accdtype = 200 + accdtype ;

Now the old 8 is 108 and the new 8 is 208 and both 108 and 208 have a constant meaning. Hence one can assign a format to the recoded ACCDTYPE without any problem.

108 = "Pedestrian" 205 = "Pedestrian" 208 = "Other"

If one has the power, simply apply the sensible coding scheme given above through out the system. If one does not have that kind of power, but does have control of the data base, recode as given above on entry into data base. In general programmers don't have this power, but they can make it a view for reports.

data db.accdview / view = db.accdview ; set db.------ ; if year ( accddate ) <= 1993 then accdtype = 100 + accdtype ; else accdtype = 200 + accdtype ; run ;

Now the report programs can refer to DB.ACCDVIEW without problem and no space is wasted trying to maintain a corrected version of a database over which you don't have control.

Ian Whitlock


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