From: Jinto83 on
Hi,

2 quick questions.

1. How to declare a variable? For example, declare VarA=numeric6.2
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 "

companyname=John's "R" Shop
desiredoutput=Johns R Shop


--- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---
From: Tom Abernathy on
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=compress(companyname,'''"');

On Mar 11, 9:26 am, "Jinto83" <jint...(a)sina.com> wrote:
> Hi,
>
>  2 quick questions.
>
> 1. How to declare a variable? For example, declare VarA=numeric6.2
>  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 "
>
> companyname=John's "R" Shop
> desiredoutput=Johns R Shop
>
> --- news://freenews.netfront.net/ - complaints: n...(a)netfront.net ---

From: Lou on

>"Jinto83" <jinto83(a)sina.com> wrote in message
>news:hnauiu$2nqm$1(a)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(a)netfront.net ---


From: Jinto83 on
Thank you so much for your answer,

What about remove a newline character(linefeed or line return) though?
cleancompanyname=compress(companyname,''\n")?


--- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---
From: Tom Abernathy on
On Mar 11, 11:11 am, "Jinto83" <jint...(a)sina.com> wrote:
> Thank  you so much for your answer,
>
> What about remove a newline character(linefeed or line return) though?
> cleancompanyname=compress(companyname,''\n")?
>
> --- news://freenews.netfront.net/ - complaints: n...(a)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