Date: Thu, 30 May 1996 11:04:45 -0400
Reply-To: Stephen McDaniel <mcdanies@LBRI.COM>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Stephen McDaniel <mcdanies@LBRI.COM>
Subject: Re: QUOTES AROUND THE TEXT
Prasad Ravi asked:
>>>
Hi:
Does anybody know how to put quotes for each observation of character
variables in a dataset?
<<<
Generally, you can add single quotes to a text variable by containing it
with double quotes, and you can add double quotes to a text variable by
containing it in single quotes. See the following code and output for an
example:
============================== PROGRAM ===============================
data test1;
input charvar1 $;
cards;
ab
ef
12
;
run;
proc print;
title 'No Quotes';
run;
*** Double Quotes Added;
data test2;
attrib charvar1 length=$4;
set test1;
charvar1='"' || trim(charvar1) || '"';
run;
proc print;
title 'Double Quotes';
run;
*** Single Quotes Added;
data test3;
attrib charvar1 length=$4;
set test1;
charvar1="'" || trim(charvar1) || "'";
run;
proc print;
title 'Single Quotes';
run;
============================== OUTPUT ===============================
No Quotes
OBS CHARVAR1
1 ab
2 ef
3 12
Double Quotes
OBS CHARVAR1
1 "ab"
2 "ef"
3 "12"
Single Quotes
OBS CHARVAR1
1 'ab'
2 'ef'
3 '12'
============================== END ===============================
See the SAS Language Reference (pg. 115, First Edition) for more info and
methods.
Best regards,
Stephen McDaniel
Senior Statistical Programmer
L.A.B. Biopharmaceutical Research International, Inc.
Durham, NC 27707
(919) 403-9794