Similar Threads:
1.How to delete (replace) specific characters in an irregular string
suppose
data t1;
x='ab, 6, c, def';
y='h, i, jk';
run;
Is there a simple way to knock out the ','s in x and y , that is to
replace ',' with 0 length empty place. As you see, x and y have irregular
patterns. The SUBSTR(Left of =) function needs specific character
positions, and the approach using INDEX() and SCAN() fucntions seems to be
too complicated. Thanks!
2.How to insert a single literal quote (") character in a string
Suppose one wants to write this string, an html tag, in an output
file:
<a name="section"></a>
The first step is to create a variable with this value. It seems like
this line would work:
tag = '<a name=' || ? || 'section' || ? || '></a>' ;
but what goes in place of the ? above?
Thanks in advance.
John Uebersax
3.gsfmode=replace does not replace
I am using the goption gsfmode=replace and I am expecting that if you
use name="xxx" on the ganno statement then when you come to run it a
second time it will "replace" what it wrote before and reuse the name
"xxx". But it does not. This is true for sas v8.2 and sas v9.1.3 .
What is wrong? How can I get it to reuse the name I have defined to
name= on "proc ganno"?
4.translate the _entire_ string, not the characters
hi SAS-L
My goal is to, without having to use INDEX*(), but using maybe
TRANSLATE() or some other function, to replace the '"' value in a
given variable (&&var&i below) for a single character quote mark. If I
use newvar = translate(&&var&i,'"','"') then all instances of each
of the characters '&','q','u','o','t' and ';' are dropped. The same
goes for '<br>': I simply want to replace this entire character
sequence with a space, but I seem to replace all instance of each of
the characters '<','b','r','>'.
I am interested in not using the index family of functions, since the
variable's values may or may not include 0, 1, or more instances of
'"'.
As well, since this is data stored in a SQL Server, I would rather not
write out to a flatt file in order to process using the @@ and then
read back in for additional processing.
Thanks in adnvance,
Greg
5.Replacing a Character variable with part of another Character
> -----Original Message-----
> From: SAS(r) Discussion [mailto: XXXX@XXXXX.COM ] On Behalf Of SAS
> Student
> Sent: Saturday, December 08, 2007 2:24 PM
> To: XXXX@XXXXX.COM
> Subject: Replacing a Character variable with part of another Character variable
>
> Good evening all,
>
> I have a small problem that I need to solve and would appreciate any
> help you offer.
> I created the below table using some raw data. I created the Location
> variable using the
> ZIPCITY function. As you can see, in the last observation the City
> "Harrisbu" does not match the city under Location "Levittown" while
> for the first observation the Location is left blank because the
> zipcode is invalid.
It will be a lot easier for people to help you if you provide a self-contained program that generates your sample data, rather than making them try to extract data from a poorly formatted email (everything is wrapping haphazardly at my end of the email).
That being said, is this just a toy problem or is this a real problem you are trying to solve. I ask, because ZIP codes are not geographical regions, but rather mail delivery routes. There are many places where the zipcode "location" does not match the town. In fact, sometimes even the state won't match. So I'm not convinced you should be editing anything.
>I need a simple code that does the following:
>
> 1.If they zipcode does not match the city/state (6th observation),
> create a code that suggests either edits to the zipcode or city/state.
What do you mean by create a code? It would be helpful if you took the sample data from your email and showed us what you would like the end result to be.
>
> 2. If the Zipcode is invalid (1st observation) i need to replace its
> value with "???"
How do you know that a ZIPCODE is invalid? Because location is blank? If you write back to SAS-L and show us what you want to end up with, someone will surely be able to give you some useful help (maybe even me :-).
Dan
Daniel Nordlund
Bothell, WA USA
6. Replacing a Character variable with part of another Character variable
7. find and replace strings
8. How to replace certain characters in a variable with '_'