f



Re: What's wrong with this: street_n=addr1_1|" "||addr2||" "||addr3||" "||addr4||" "||addr5 #4

Thank you for the code.  That's what I really wanted to see.
I have some problem in understanding the code: particularly,  ` '0'* <^w ?*> from your code  rx = rxparse("` '0'* <^w ?*> to =1");
I know the tag expression and *, but I do not understand the rest characters.  Can you explain it for me?

Many thanks,
Duckhye

>>> "Chang Y. Chung" <chang_y_chung@HOTMAIL.COM> 03/04/04 01:36PM >>>
On Thu, 4 Mar 2004 12:55:20 -0600, Duck-Hye Yang <dyang@CHAPINHALL.ORG>
wrote:

>Hi,
>I wanted to remove the first zero  from 0416 E. BAILEY  101, but not from
>0 S 356 MADISON.
>I ran the following code and I have problem with the line:
>------------------------
>street_n=addr1_1|" "||addr2||" "||addr3||" "||addr4||" "||addr5;
>----------------------
>

Hi, Duck-Hye,

You need to add one more bar character after addr1_1 for the above line.

For removing the leading zeros, try the following rx solution.

Cheers,
Chang

<sasl:code>
/* test data */
options nocenter;
data one;
  length line $50;
  line = "0416 E. BAILEY  101"; output;
  line = "0016 E. BAILEY  101"; output;
  line = "0001 E. BAILEY  101"; output;
  line = "0 S 356 MADISON";     output;
  line = "00 S 356 MADISON";    output;
run;

data two;
  set one;
  if _n_ =1 then do;
   length new_line $50;
 /* remove any leading 0^s without immediately following non-white
space */
 drop rx;
 rx = rxparse("` '0'* <^w ?*> to =1");
 retain rx;
  end;
  call rxchange(rx, 1, line, new_line);
run;
proc print data=two;
run;
/* on lst
Obs           line                 new_line

 1     0416 E. BAILEY  101    416 E. BAILEY  101
 2     0016 E. BAILEY  101    16 E. BAILEY  101
 3     0001 E. BAILEY  101    1 E. BAILEY  101
 4     0 S 356 MADISON        0 S 356 MADISON
 5     00 S 356 MADISON       0 S 356 MADISON
*/
</sasl:code>
0
dyang (97)
3/4/2004 11:16:33 PM
comp.soft-sys.sas 142827 articles. 4 followers. Post Follow

0 Replies
776 Views

Similar Articles

[PageSpeed] 7

Reply: