|Date: ||Mon, 20 Oct 2003 09:15:30 -0700|
|Reply-To: ||Charles Patridge <charles_s_patridge@PRODIGY.NET>|
|Sender: ||"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>|
|From: ||Charles Patridge <charles_s_patridge@PRODIGY.NET>|
|Subject: ||Re: SV: Re: IF-THEN recode problem|
|Content-Type: ||text/plain; charset=us-ascii|
I missed the use of "and" and saw someone else mention this. That is really your problem as pointed out.
I would like to say that Ron Fehd has an extremely useful suggestion - learn the substr, index, verify functions - they are and can be very useful for you in your quest to cleanse/parse your data.
Sorry to mislead you on my thoughts - just did not read between the words careful enough.
Dave Sorensen <Dave.Sorensen@jur.ku.dk> wrote:
Dear Ron, Charles, James and Robert,
What a wonderful help SAS-L can be for us green types!
I was in the midst of writing a response (attached below) to you , Ron and Charles, when new responses from James and Robert showed up. Robert Bardos' response was very simple looking and, being a simple guy, I tried it and it ran perfectly. So I am all set. Thanks, Robert! (I now also note that James Green's code was nearly identical to Robert's. So thanks, James!)
In case you have any remaining interest in the problem, I detail it more fully below in the email I had already strated when James and Robert's responses came in. This will probably make my original errors easily apparent to you maveriks one and all.
Thanks you very much everyone,
Dear Ron and Charles,
I checked the variable attributes in Proc Contents, and I assume they are character vars.
# Variable Type Len Pos
3 Address Char 35 35
1 Number Char 10 0
2 Street Char 25 10
Though I have a lot of recoding to do, just one problematic recode (and associated log notes) may demonstrate the problem more concretely perhaps.
The problem with the address data below is that the data entry person has entered both the street name and the house number into the STREET variable, and left the NUMBER variable blank. (Note that this is a Danish street address. In Denmark, the street name precedes the house number).
Street Number Address
Finmarken 126 Finmarken 126
While the ADDRESS variable still looks okay (since it is a concatenation of STREET and NUMBER), I still want to get the original STREET and NUMBER variables entered correctly.
I ran the following recode to try to fix the problem manually:
If Address= 'Finmarken 126' then Street='Finmarken' and Number='126';
The log file is as follows:
2310 Data us2;
2311 set us;
2312 If address= 'Finmarken 126' then Street='Finmarken' and Number='126';
NOTE: Character values have been converted to numeric values at the places given by:
NOTE: Numeric values have been converted to character values at the places given by:
NOTE: Invalid numeric data, 'Finmarken' , at line 2312 column 42.
Number= Street=0 Address=Finmarken 126 _ERROR_=1 _N_=17346
NOTE: There were 87471 observations read from the data set WORK.US.
NOTE: The data set WORK.US2 has 87471 observations and 3 variables.
NOTE: DATA statement used:
real time 0.16 seconds
And a Proc Print on the result is as follows:
Street Number Address
0 Finmarken 126
MANY THANKS AGAIN !!!
Fra: Charles Patridge [mailto:charles_s_patridge@PRODIGY.NET]
Sendt: 20. oktober 2003 17:26
Emne: Re: IF-THEN recode problem
You did state your variables all have "character" attributes but it would
seem that one of them is defined as numeric.
Check your variable attributes once again from your dataset "old" just to
Charles S Patridge - PDPC, Ltd.
172 Monce Road - Burlington, CT 06013 USA