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 (October 2003, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 20 Oct 2003 18:10:05 +0200
Reply-To:     Dave Sorensen <Dave.Sorensen@JUR.KU.DK>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Dave Sorensen <Dave.Sorensen@JUR.KU.DK>
Subject:      SV:      Re: IF-THEN recode problem
Comments: To: rjf2@CDC.GOV, Charles Patridge <charles_s_patridge@PRODIGY.NET>,
          james.green@alcatel.com, bardos2@ANSYS.CH
Content-Type: text/plain; charset="iso-8859-1"

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,

Dave

Dear Ron and Charles,

I checked the variable attributes in Proc Contents, and I assume they are character vars.

# Variable Type Len Pos fffffffffffffffffffffffffffffffffff 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).

PROC PRINT

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:

Data us2; set us; If Address= 'Finmarken 126' then Street='Finmarken' and Number='126'; run;

The log file is as follows:

2310 Data us2; 2311 set us; 2312 If address= 'Finmarken 126' then Street='Finmarken' and Number='126'; 2313 run;

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column). 2312:42 NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column). 2312:54 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:

PROC PRINT

Street Number Address 0 Finmarken 126

MANY THANKS AGAIN !!!

Dave Sorensen

-----Oprindelig meddelelse----- Fra: Charles Patridge [mailto:charles_s_patridge@PRODIGY.NET] Sendt: 20. oktober 2003 17:26 Til: SAS-L@LISTSERV.UGA.EDU Emne: Re: IF-THEN recode problem

Dave,

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 be sure.

HTH, Charles Patridge


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