Adding single quote to a data in sas

Reply
Contributor
Posts: 39

Adding single quote to a data in sas

data test;

input id 5.;

datalines;

11111

12345

14524

45246

;

run;

The quote function adds double quotes to the data, but I wanted to add the single quote.. %BQUOTE And %STR seems not working.

data test2;

set test;

id_new=quote(id);

run;

******

desired output;

id

'11111'

'12345'

'14524'

'45246'

Thanks in advance

PLease help.


Super User
Posts: 19,167

Re: Adding single quote to a data in sas

Can concatenate in single quotes.
The single quotes are quoted by double quotes in the following example:

data want;

    set test;

    id_quote=catt("'", id, "'");

run;

Contributor
Posts: 39

Re: Adding single quote to a data in sas

Thanks much

Respected Advisor
Posts: 3,788

Re: Adding single quote to a data in sas

You can use one of these functions.  One method is not documented.

data test;
input id $5.;
datalines;
11111
12345
14524
45246
;
run;

data test2;
   set test;
   id_new=quote(id,"'");
   id_new2=catq('1A',id);
   run;
proc print;
  
run;


12-1-2014 4-23-19 PM.png
Ask a Question
Discussion stats
  • 3 replies
  • 206 views
  • 4 likes
  • 3 in conversation