Date: Fri, 13 Apr 2007 16:02:05 -0400
Reply-To: Chang Chung <chang_y_chung@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Chang Chung <chang_y_chung@HOTMAIL.COM>
Subject: Re: Single quotes around CSV
On Fri, 13 Apr 2007 11:41:39 -0700, Nordlund, Dan (DSHS/RDA)
<NordlDJ@DSHS.WA.GOV> wrote:
...
>Does the database you are connecting to require single quotes, or will
double quotes work? If double quotes are ok then you could do something like
the code below. Separate the provider numbers by double-quote, comma,
double-quote, (ie, ",") and then wrap your macro variable reference in
double-quotes in the IN() clause.
>
>proc sql;
> select distinct provno
> into :entered separated by '","'
> from final;
>quit;
>
>proc sql;
> connect to odbc as DW (dsn="&dsnname" uid=blah pwd=blah);
> create table cnhmas as
> select *
> from connection to DW (
> select *
> from &dsnname..CNHMAS where provno
> in ("&provlist"));
>quit;
Hi,
I know I should keep my mouth shut, and not nit-pick... but could not help
myself doing it today... :-(
On single/double quotes, this does not matter much, since we can always
double up and add the single quotes later with %let:
proc sql noprint;
select name into :names separated by ''','''
from sashelp.class;
quit;
%let names = %unquote(%str(%')&names%str(%'));
%put _user_;
But original questioner's code will never work as expected since s/he
generates the list into macro variable "entered," and tries to reference it
with "provlist"! :-O
Cheers,
Chang
|