Date: Thu, 29 Oct 2009 08:30:04 -0400
Reply-To: D T <sasandstats@LIVE.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: D T <sasandstats@LIVE.COM>
Subject: Re: SUSPECT: RE: [SAS-L]: macro varlist needs to be separated by
quotes and commas
In-Reply-To: <683E39A2DCFA4D42A8A08821DDC049DD03AD6FCF@DOMSRV.HSP.CSDT.ES>
Content-Type: multipart/alternative;
X-OriginalArrivalTime: 29 Oct 2009 12:30:04.0053 (UTC) FILETIME=[8A7F8450:01CA5893]
X-Scanned-By: Digested by UGA Mail Gateway on 128.192.1.75
<683E39A2DCFA4D42A8A08821DDC049DD03AD6FCF@DOMSRV.HSP.CSDT.ES>
MIME-Version: 1.0
--_4f06695f-cc77-4809-a53b-0c959a0b0c06_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Daniel=2C
thank you so much! It worked using this work around!
DT.
> Date: Thu=2C 29 Oct 2009 12:35:07 +0100
> From: DFernandez@CST.CAT
> Subject: Re: [SAS-L] SUSPECT: RE: [SAS-L]: macro varlist needs to be =
separated by quotes and commas
> To: SAS-L@LISTSERV.UGA.EDU
>=20
> Yeah!
>=20
> =20
>=20
> Quote/2 function!! NOT REAL=2C I am just kidding... TRY THIS:
>=20
> =20
>=20
> "'"||strip(yourvarname)||"'"
>=20
> =20
>=20
> proc sql noprint=3B
>=20
> select distinct "'"||strip(name)||"'"=2C
>=20
> "'"||strip(sex)||"'"
>=20
> into:namelist separated by '=2C'=2C
>=20
> :sexlist separated by '=2C'
>=20
> from sashelp.class
>=20
> where
>=20
> upcase(name) in ('MARY'=2C'THOMAS')=3B
>=20
> quit=3B
>=20
> =20
>=20
> %put &namelist &sexlist=3B.
>=20
> =20
>=20
> Daniel Fernandez.
> BArcelona
>=20
> =20
>=20
> =20
>=20
> =20
>=20
> =20
>=20
> =20
>=20
> ________________________________
>=20
> De: D T [mailto:sasandstats@live.com]=20
> Enviado el: dijous=2C 29 / octubre / 2009 12:22
> Para: Fern=E1ndez Rodr=EDguez=2C Dani=3B sas-l@listserv.uga.edu
> Asunto: SUSPECT: RE: [SAS-L]: macro varlist needs to be separated by quot=
es and commas
>=20
> =20
>=20
> Thanks=2C Dan and Daniel.
>=20
> Is there a way to get single quotes only=2C insted of double quotes? I am=
running this in sybase=2C and it is not liking the double quotes.
>=20
> DT.
>=20
> > Subject: RE: SUSPECT: macro varlist needs to be separated by quotes and=
commas
> > Date: Thu=2C 29 Oct 2009 10:50:32 +0100
> > From: DFernandez@CST.CAT
> > To: sasandstats@LIVE.COM=3B SAS-L@LISTSERV.UGA.EDU
> >=20
> > Hi=2C
> >=20
> > Yeah you can use Quote function inside the SQL select like this:
> >=20
> > proc sql noprint=3B
> > select distinct quote(strip(name))=2C
> > quote(strip(sex))
> > into:namelist separated by '=2C'=2C
> > :sexlist separated by '=2C'
> > from sashelp.class
> > where
> > upcase(name) in ('MARY'=2C'THOMAS')=3B
> > quit=3B
> >=20
> > %put &namelist &sexlist=3B
> >=20
> > It would be good you use Strip function to not pass blanks to macro var=
iable.
> >=20
> > Daniel Fernandez.
> > BArcelona
> >=20
> > -----Mensaje original-----
> > De: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] En nombre de D T
> > Enviado el: dijous=2C 29 / octubre / 2009 01:18
> > Para: SAS-L@LISTSERV.UGA.EDU
> > Asunto: SUSPECT: macro varlist needs to be separated by quotes and comm=
as
> >=20
> > I have a list of character variables that needs to be used in
> > a subsequent step to extract more detail linked to the IDs in the list.=
The IDs
> > contain numbers and letters=2C and need to be quoted when used. How can=
that be
> > done? Can the quotes be added when the list is created? Or can the quot=
es be added when
> > I evoke the list in the second step?
> >=20
> >=20
> >=20
> > Here is what I have so far:
> >=20
> >=20
> >=20
> > proc sql
> > noprint=3B
> >=20
> > select
> > distinct pdid=2C id2
> >=20
> > into
> > :plist separated by '=2C'=2C
> >=20
> > :idlist
> > separated by '=2C'
> >=20
> > from madeup
> >=20
> > where
> > pdid in ('899G'=2C'8995'=2C'5902'=2C'344D'=2C'8997')=3B
> >=20
> > quit=3B
> >=20
> >=20
> >=20
> > %put
> > &plist &idlist=3B
> >=20
> >=20
> >=20
> > proc sql=3B
> >=20
> > select
> > pdid=2C=20
> >=20
> > id2=2C
> >=20
> > demo1=2C
> >=20
> > demo2=2C
> >=20
> > demo3
> >=20
> > from demodat
> >=20
> > where
> >=20
> > pdid
> >=20
> > in (&plist)
> >=20
> >=20
> > and=20
> >=20
> > id2 in
> > (&idlist)=20
> >=20
> > and
> >=20
> > year(date)
> > in (2006)=3B
> >=20
> > quit=3B
> >=20
> >=20
> >=20
> > This
> > does not work because both sets of IDs need to be quoted in addition to=
being
> > separated by commas.=20
> >=20
> >=20
> >=20
> > Your help is appreciated. Thanks!
> >=20
> > DT.
> >=20
> >=20
> > _________________________________________________________________
> > Windows 7: It helps you do more. Explore Windows 7.
> > http://www.microsoft.com/Windows/windows-7/default.aspx?ocid=3DPID24727=
::T:WLMTAGL:ON:WL:en-US:WWL_WIN_evergreen3:102009
>=20
> ________________________________
>=20
> Windows 7: It works the way you want. Learn more. <http://www.microsoft.c=
om/Windows/windows-7/default.aspx?ocid=3DPID24727::T:WLMTAGL:ON:WL:en-US:WW=
L_WIN_evergreen2:102009>=20
=20
_________________________________________________________________
Windows 7: Simplify your PC. Learn more.
http://www.microsoft.com/Windows/windows-7/default.aspx?ocid=3DPID24727::T:=
WLMTAGL:ON:WL:en-US:WWL_WIN_evergreen1:102009=
--_4f06695f-cc77-4809-a53b-0c959a0b0c06_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<style><!--
.hmmessage P
{
margin:0px=3B
padding:0px
}
body.hmmessage
{
font-size: 10pt=3B
font-family:Verdana
}
--></style>
</head>
<body class=3D'hmmessage'>
Daniel=2C<br><br>thank you so much! It worked using this work around!<br><b=
r>DT.<br><br>>=3B Date: Thu=2C 29 Oct 2009 12:35:07 +0100<br>>=3B From:=
DFernandez@CST.CAT<br>>=3B Subject: Re: [SAS-L] SUSPECT: RE: [SAS-L]: ma=
cro varlist needs to be separated by quotes and c=
ommas<br>>=3B To: SAS-L@LISTSERV.UGA.EDU<br>>=3B <br>>=3B Yeah!<br>&g=
t=3B <br>>=3B <br>>=3B <br>>=3B Quote/2 function!! NOT REAL=2C I am=
just kidding... TRY THIS:<br>>=3B <br>>=3B <br>>=3B <br>>=3B "'"|=
|strip(yourvarname)||"'"<br>>=3B <br>>=3B <br>>=3B <br>>=3B proc s=
ql noprint=3B<br>>=3B <br>>=3B select distinct "'"||strip(name)||"'"=2C=
<br>>=3B <br>>=3B "'"||strip(sex)||"'"<br>>=
=3B <br>>=3B into:namelist separated by '=2C'=
=2C<br>>=3B <br>>=3B :sexlist separated by '=2C'<=
br>>=3B <br>>=3B from sashelp.class<br>>=3B <br>>=3B where<br>>=
=3B <br>>=3B upcase(name) in ('MARY'=2C'THOMAS')=3B<br>>=3B <br>>=3B =
quit=3B<br>>=3B <br>>=3B <br>>=3B <br>>=3B %put &=3Bnamelist =
&=3Bsexlist=3B.<br>>=3B <br>>=3B <br>>=3B <br>>=3B Daniel F=
ernandez.<br>>=3B BArcelona<br>>=3B <br>>=3B <br>>=3B <br>>=3B =
<br>>=3B <br>>=3B <br>>=3B <br>>=3B <br>>=3B <br>>=3B <br>&g=
t=3B <br>>=3B ________________________________<br>>=3B <br>>=3B De: D=
T [mailto:sasandstats@live.com] <br>>=3B Enviado el: dijous=2C 29 / octu=
bre / 2009 12:22<br>>=3B Para: Fern=E1ndez Rodr=EDguez=2C Dani=3B sas-l@l=
istserv.uga.edu<br>>=3B Asunto: SUSPECT: RE: [SAS-L]: macro varlist needs=
to be separated by quotes and commas<br>>=3B <br>>=3B <br>>=3B <br>=
>=3B Thanks=2C Dan and Daniel.<br>>=3B <br>>=3B Is there a way to get=
single quotes only=2C insted of double quotes? I am running this in sybase=
=2C and it is not liking the double quotes.<br>>=3B <br>>=3B DT.<br>>=
=3B <br>>=3B >=3B Subject: RE: SUSPECT: macro varlist needs to be separ=
ated by quotes and commas<br>>=3B >=3B Date: Thu=2C 29 Oct 2009 10:50:3=
2 +0100<br>>=3B >=3B From: DFernandez@CST.CAT<br>>=3B >=3B To: sasa=
ndstats@LIVE.COM=3B SAS-L@LISTSERV.UGA.EDU<br>>=3B >=3B <br>>=3B >=
=3B Hi=2C<br>>=3B >=3B <br>>=3B >=3B Yeah you can use Quote functio=
n inside the SQL select like this:<br>>=3B >=3B <br>>=3B >=3B proc =
sql noprint=3B<br>>=3B >=3B select distinct quote(strip(name))=2C<br>&g=
t=3B >=3B quote(strip(sex))<br>>=3B >=3B into:namelist separated by '=
=2C'=2C<br>>=3B >=3B :sexlist separated by '=2C'<br>>=3B >=3B from =
sashelp.class<br>>=3B >=3B where<br>>=3B >=3B upcase(name) in ('MAR=
Y'=2C'THOMAS')=3B<br>>=3B >=3B quit=3B<br>>=3B >=3B <br>>=3B >=
=3B %put &=3Bnamelist &=3Bsexlist=3B<br>>=3B >=3B <br>>=3B >=
=3B It would be good you use Strip function to not pass blanks to macro var=
iable.<br>>=3B >=3B <br>>=3B >=3B Daniel Fernandez.<br>>=3B >=
=3B BArcelona<br>>=3B >=3B <br>>=3B >=3B -----Mensaje original-----=
<br>>=3B >=3B De: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] En =
nombre de D T<br>>=3B >=3B Enviado el: dijous=2C 29 / octubre / 2009 01=
:18<br>>=3B >=3B Para: SAS-L@LISTSERV.UGA.EDU<br>>=3B >=3B Asunto: =
SUSPECT: macro varlist needs to be separated by quotes and commas<br>>=3B=
>=3B <br>>=3B >=3B I have a list of character variables that needs t=
o be used in<br>>=3B >=3B a subsequent step to extract more detail link=
ed to the IDs in the list. The IDs<br>>=3B >=3B contain numbers and let=
ters=2C and need to be quoted when used. How can that be<br>>=3B >=3B d=
one? Can the quotes be added when the list is created? Or can the quotes be=
added when<br>>=3B >=3B I evoke the list in the second step?<br>>=3B=
>=3B <br>>=3B >=3B <br>>=3B >=3B <br>>=3B >=3B Here is what =
I have so far:<br>>=3B >=3B <br>>=3B >=3B <br>>=3B >=3B <br>>=
=3B >=3B proc sql<br>>=3B >=3B noprint=3B<br>>=3B >=3B <br>>=3B=
>=3B select<br>>=3B >=3B distinct pdid=2C id2<br>>=3B >=3B <br>&=
gt=3B >=3B into<br>>=3B >=3B :plist separated by '=2C'=2C<br>>=3B &=
gt=3B <br>>=3B >=3B :idlist<br>>=3B >=3B separated by '=2C'<br>>=
=3B >=3B <br>>=3B >=3B from madeup<br>>=3B >=3B <br>>=3B >=3B=
where<br>>=3B >=3B pdid in ('899G'=2C'8995'=2C'5902'=2C'344D'=2C'8997'=
)=3B<br>>=3B >=3B <br>>=3B >=3B quit=3B<br>>=3B >=3B <br>>=3B=
>=3B <br>>=3B >=3B <br>>=3B >=3B %put<br>>=3B >=3B &=3Bpl=
ist &=3Bidlist=3B<br>>=3B >=3B <br>>=3B >=3B <br>>=3B >=3B <=
br>>=3B >=3B proc sql=3B<br>>=3B >=3B <br>>=3B >=3B select<br>&=
gt=3B >=3B pdid=2C <br>>=3B >=3B <br>>=3B >=3B id2=2C<br>>=3B &=
gt=3B <br>>=3B >=3B demo1=2C<br>>=3B >=3B <br>>=3B >=3B demo2=
=2C<br>>=3B >=3B <br>>=3B >=3B demo3<br>>=3B >=3B <br>>=3B &g=
t=3B from demodat<br>>=3B >=3B <br>>=3B >=3B where<br>>=3B >=3B=
<br>>=3B >=3B pdid<br>>=3B >=3B <br>>=3B >=3B in (&=3Bplist=
)<br>>=3B >=3B <br>>=3B >=3B <br>>=3B >=3B and <br>>=3B >=
=3B <br>>=3B >=3B id2 in<br>>=3B >=3B (&=3Bidlist) <br>>=3B &g=
t=3B <br>>=3B >=3B and<br>>=3B >=3B <br>>=3B >=3B year(date)<br=
>>=3B >=3B in (2006)=3B<br>>=3B >=3B <br>>=3B >=3B quit=3B<br>&=
gt=3B >=3B <br>>=3B >=3B <br>>=3B >=3B <br>>=3B >=3B This<br>=
>=3B >=3B does not work because both sets of IDs need to be quoted in a=
ddition to being<br>>=3B >=3B separated by commas. <br>>=3B >=3B <b=
r>>=3B >=3B <br>>=3B >=3B <br>>=3B >=3B Your help is appreciate=
d. Thanks!<br>>=3B >=3B <br>>=3B >=3B DT.<br>>=3B >=3B <br>>=
=3B >=3B <br>>=3B >=3B ______________________________________________=
___________________<br>>=3B >=3B Windows 7: It helps you do more. Explo=
re Windows 7.<br>>=3B >=3B http://www.microsoft.com/Windows/windows-7/d=
efault.aspx?ocid=3DPID24727::T:WLMTAGL:ON:WL:en-US:WWL_WIN_evergreen3:10200=
9<br>>=3B <br>>=3B ________________________________<br>>=3B <br>>=
=3B Windows 7: It works the way you want. Learn more. <=3Bhttp://www.micr=
osoft.com/Windows/windows-7/default.aspx?ocid=3DPID24727::T:WLMTAGL:ON:WL:e=
n-US:WWL_WIN_evergreen2:102009>=3B <br> <br /><hr />Windows 7:=
Simplify your PC. <a href=3D'http://www.microsoft.com/Windows/windows-7/de=
fault.aspx?ocid=3DPID24727::T:WLMTAGL:ON:WL:en-US:WWL_WIN_evergreen1:102009=
' target=3D'_new'>Learn more.</a></body>
</html>=
--_4f06695f-cc77-4809-a53b-0c959a0b0c06_--