Hi,
2 quick questions.
1. How to declare a variable? For example, declare VarA=3Dnumeric6.2=20
Is it using put or input?
2. How to remove all occurence of the symbol ' and the symbol "
Tranwrd in SAS won't take ' or "=20
companyname=3DJohn's "R" Shop
desiredoutput=3DJohns R Shop
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
|
|
0
|
|
|
|
Reply
|
Jinto83
|
3/11/2010 2:26:34 PM |
|
1) use the ATTRIB statement or a combination of LENGTH, FORMAT,
INFORMAT and LABEL statements.
2) Use the COMPRESS function to remove characters. TRANWRD is for
translating strings from one to another.
cleancompanyname=3Dcompress(companyname,'''"');
On Mar 11, 9:26=A0am, "Jinto83" <jint...@sina.com> wrote:
> Hi,
>
> =A02 quick questions.
>
> 1. How to declare a variable? For example, declare VarA=3Dnumeric6.2
> =A0Is it using put or input?
> 2. How to remove all occurence of the symbol ' and the symbol "
> Tranwrd in SAS won't take ' or "
>
> companyname=3DJohn's "R" Shop
> desiredoutput=3DJohns R Shop
>
> --- news://freenews.netfront.net/ - complaints: n...@netfront.net ---
|
|
0
|
|
|
|
Reply
|
Tom
|
3/11/2010 2:46:29 PM
|
|
Thank you so much for your answer,
What about remove a newline character(linefeed or line return) though?
cleancompanyname=3Dcompress(companyname,''\n")?
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
|
|
0
|
|
|
|
Reply
|
Jinto83
|
3/11/2010 4:11:55 PM
|
|
>"Jinto83" <jinto83@sina.com> wrote in message
>news:hnauiu$2nqm$1@adenine.netfront.net...
>Hi,
>
>2 quick questions.
>
>1. How to declare a variable? For example, declare VarA=numeric6.2
>Is it using put or input?
The most complete declaration uses the ATTRIB statement. You can do
"partial" declarations with statements like LENGTH, FORMAT, and INFORMAT.
Or you can not worry about it and let SAS handle the declarations implicitly
from context. No guarantees that SAS will assign what you really want.
>2. How to remove all occurence of the symbol ' and the symbol "
>Tranwrd in SAS won't take ' or "
>
>companyname=John's "R" Shop
>desiredoutput=Johns R Shop
TRANWRD can handel multiple character string targets, while TRANSLATE works
on single character targets, and it appears that you're working with single
characters. Either can handle single or double quotes if you quote things
properly, though the quoting can cause a case of fumble fingers, like so:
84 data _null_;
85 companyname = "John's " || '"R" Shop';
86 put companyname=;
87 newname = translate(companyname, ' ', "'", ' ', '"');
88 put newname=;
89 run;
companyname=John's "R" Shop
newname=John s R Shop
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
|
|
0
|
|
|
|
Reply
|
Lou
|
3/11/2010 6:20:50 PM
|
|
On Mar 11, 11:11=A0am, "Jinto83" <jint...@sina.com> wrote:
> Thank =A0you so much for your answer,
>
> What about remove a newline character(linefeed or line return) though?
> cleancompanyname=3Dcompress(companyname,''\n")?
>
> --- news://freenews.netfront.net/ - complaints: n...@netfront.net ---
You can specify characters using hexcodes by enclosing in quotes and
suffixing with X.
Carriage return is '0D'x
Line Feed is '0A'x
Form Feed is '0C'x
Tab is '09'x
Or all together is '090A0C0D'x
|
|
0
|
|
|
|
Reply
|
Tom
|
3/12/2010 12:31:43 AM
|
|
|
4 Replies
394 Views
(page loaded in 0.024 seconds)
|