Date: Thu, 29 Oct 2009 07:52:43 -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: macro varlist needs to be separated by quotes and commas
In-Reply-To: <683E39A2DCFA4D42A8A08821DDC049DD03AD6FE9@DOMSRV.HSP.CSDT.ES>
Content-Type: multipart/alternative;
<683E39A2DCFA4D42A8A08821DDC049DD03AD6FE9@DOMSRV.HSP.CSDT.ES>
MIME-Version: 1.0
--_9c06af7f-d735-4930-b67a-4fe5bd730e1e_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Ruslan=2C
Daniel is correct. I thought of the same approach yesterday=2C but could no=
t resolve how to fix the first and last value. If you can=2C please let me =
know how you would add the two missing quotes before using the varlist in a=
nother data or proc sql step--I'd be interested!
Thanks!
DT.
> Date: Thu=2C 29 Oct 2009 12:44:58 +0100
> From: DFernandez@CST.CAT
> Subject: Re: [SAS-L] macro varlist needs to be separated by quotes and =
commas
> To: SAS-L@LISTSERV.UGA.EDU
>=20
> Hi Ruslan=2C
>=20
> This way will be incorrect=2C you are forgetting the first observation.
> If variable contains two observation=2C example: JOHN=2CDORIS
> the 'separated by '"=2C"' will output:
>=20
> JOHN"=2C"DORIS
>=20
> Daniel Fernandez.
> Barcelona
>=20
>=20
>=20
>=20
> -----Mensaje original-----
> De: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] En nombre de Ruslan=
Kirhizau
> Enviado el: dijous=2C 29 / octubre / 2009 12:38
> Para: SAS-L@LISTSERV.UGA.EDU
> Asunto: Re: macro varlist needs to be separated by quotes and commas
>=20
> separated by '"=2C"' . Leading and trailing quotes can be added when you =
use this list
> Sent on the Now Network from my Sprint=AE BlackBerry
>=20
> -----Original Message-----
> From: "Nordlund=2C Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
> Date: Wed=2C 28 Oct 2009 17:38:59
> To: <SAS-L@LISTSERV.UGA.EDU>
> Subject: Re: macro varlist needs to be separated by quotes and comma=
s
>=20
> > -----Original Message-----
> > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of D =
T
> > Sent: Wednesday=2C October 28=2C 2009 5:18 PM
> > To: SAS-L@LISTSERV.UGA.EDU
> > Subject: macro varlist needs to be separated by quotes and commas
> >
> > 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?
> >
> >
> >
> > Here is what I have so far:
> >
> >
> >
> > proc sql
> > noprint=3B
> >
> > select
> > distinct pdid=2C id2
> >
> > into
> > :plist separated by '=2C'=2C
> >
> > :idlist
> > separated by '=2C'
> >
> > from madeup
> >
> > where
> > pdid in ('899G'=2C'8995'=2C'5902'=2C'344D'=2C'8997')=3B
> >
> > quit=3B
> >
> >
> >
> > %put
> > &plist &idlist=3B
> >
> >
> >
> > proc sql=3B
> >
> > select
> > pdid=2C
> >
> > id2=2C
> >
> > demo1=2C
> >
> > demo2=2C
> >
> > demo3
> >
> > from demodat
> >
> > where
> >
> > pdid
> >
> > in (&plist)
> >
> >
> > and
> >
> > id2 in
> > (&idlist)
> >
> > and
> >
> > year(date)
> > in (2006)=3B
> >
> > quit=3B
> >
> >
> >
> > This
> > does not work because both sets of IDs need to be quoted in addition to=
being
> > separated by commas.
> >
> >
> >
> > Your help is appreciated. Thanks!
> >
> > DT.
> >
>=20
> Here is one option. If tell us more about what you are going to do with =
the list=2C other options may be better/required. If double quotes are OK=
=2C use the quote() function
>=20
> proc sql =3B
> select quote(pdid) into: plist separated by '=2C'
> from madeup
> =3B
> quit=3B
>=20
> Hope this is helpful=2C
>=20
> Dan
>=20
> Daniel J. Nordlund
> Washington State Department of Social and Health Services
> Planning=2C Performance=2C and Accountability
> Research and Data Analysis Division
> Olympia=2C WA 98504-5204
=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=
--_9c06af7f-d735-4930-b67a-4fe5bd730e1e_
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'>
Ruslan=2C<br><br>Daniel is correct. I thought of the same approach yesterda=
y=2C but could not resolve how to fix the first and last value. If you can=
=2C please let me know how you would add the two missing quotes before usin=
g the varlist in another data or proc sql step--I'd be interested!<br><br>T=
hanks!<br>DT.<br><br>>=3B Date: Thu=2C 29 Oct 2009 12:44:58 +0100<br>>=
=3B From: DFernandez@CST.CAT<br>>=3B Subject: Re: [SAS-L] macro varlist n=
eeds to be separated by quotes and commas<br>>=3B To: SAS-L@=
LISTSERV.UGA.EDU<br>>=3B <br>>=3B Hi Ruslan=2C<br>>=3B <br>>=3B Thi=
s way will be incorrect=2C you are forgetting the first observation.<br>>=
=3B If variable contains two observation=2C example: JOHN=2CDORIS<br>>=3B=
the 'separated by '"=2C"' will output:<br>>=3B <br>>=3B JOHN"=2C"DORIS=
<br>>=3B <br>>=3B Daniel Fernandez.<br>>=3B Barcelona<br>>=3B <br>&=
gt=3B <br>>=3B <br>>=3B <br>>=3B -----Mensaje original-----<br>>=3B=
De: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] En nombre de Ruslan =
Kirhizau<br>>=3B Enviado el: dijous=2C 29 / octubre / 2009 12:38<br>>=
=3B Para: SAS-L@LISTSERV.UGA.EDU<br>>=3B Asunto: Re: macro varlist needs =
to be separated by quotes and commas<br>>=3B <br>>=3B separated by '"=
=2C"' . Leading and trailing quotes can be added when you use this list<br>=
>=3B Sent on the Now Network from my Sprint=AE BlackBerry<br>>=3B <br>&=
gt=3B -----Original Message-----<br>>=3B From: "Nordlund=2C Dan (DSHS/RDA=
)" <=3BNordlDJ@DSHS.WA.GOV>=3B<br>>=3B Date: Wed=2C 28 Oct 20=
09 17:38:59<br>>=3B To: <=3BSAS-L@LISTSERV.UGA.EDU>=3B<br>>=3B Subj=
ect: Re: macro varlist needs to be separated by quotes and commas<br>&=
gt=3B <br>>=3B >=3B -----Original Message-----<br>>=3B >=3B From: S=
AS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of D T<br>>=3B=
>=3B Sent: Wednesday=2C October 28=2C 2009 5:18 PM<br>>=3B >=3B To: =
SAS-L@LISTSERV.UGA.EDU<br>>=3B >=3B Subject: macro varlist needs to be =
separated by quotes and commas<br>>=3B >=3B<br>>=3B >=3B I have a l=
ist of character variables that needs to be used in<br>>=3B >=3B a subs=
equent step to extract more detail linked to the IDs in the list. The IDs<b=
r>>=3B >=3B contain numbers and letters=2C and need to be quoted when u=
sed. How can that be<br>>=3B >=3B done? Can the quotes be added when th=
e list is created? Or can the quotes be<br>>=3B >=3B 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>&=
gt=3B >=3B noprint=3B<br>>=3B >=3B<br>>=3B >=3B select<br>>=3B =
>=3B distinct pdid=2C id2<br>>=3B >=3B<br>>=3B >=3B into<br>>=
=3B >=3B :plist separated by '=2C'=2C<br>>=3B >=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 pd=
id in ('899G'=2C'8995'=2C'5902'=2C'344D'=2C'8997')=3B<br>>=3B >=3B<br>&=
gt=3B >=3B quit=3B<br>>=3B >=3B<br>>=3B >=3B<br>>=3B >=3B<br>=
>=3B >=3B %put<br>>=3B >=3B &=3Bplist &=3Bidlist=3B<br>>=3B=
>=3B<br>>=3B >=3B<br>>=3B >=3B<br>>=3B >=3B proc sql=3B<br>&=
gt=3B >=3B<br>>=3B >=3B select<br>>=3B >=3B pdid=2C<br>>=3B >=
=3B<br>>=3B >=3B id2=2C<br>>=3B >=3B<br>>=3B >=3B demo1=2C<br>&=
gt=3B >=3B<br>>=3B >=3B demo2=2C<br>>=3B >=3B<br>>=3B >=3B de=
mo3<br>>=3B >=3B<br>>=3B >=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 (&=
amp=3Bidlist)<br>>=3B >=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>>=3B >=3B<br>>=3B >=3B<br>>=3B >=3B<br>&g=
t=3B >=3B This<br>>=3B >=3B does not work because both sets of IDs ne=
ed to be quoted in addition to being<br>>=3B >=3B separated by commas.<=
br>>=3B >=3B<br>>=3B >=3B<br>>=3B >=3B<br>>=3B >=3B Your he=
lp is appreciated. Thanks!<br>>=3B >=3B<br>>=3B >=3B DT.<br>>=3B =
>=3B<br>>=3B <br>>=3B Here is one option. If tell us more about what=
you are going to do with the list=2C other options may be better/required.=
If double quotes are OK=2C use the quote() function<br>>=3B <br>>=3B =
proc sql =3B<br>>=3B select quote(pdid) into: plist separated by '=2C'<=
br>>=3B from madeup<br>>=3B =3B<br>>=3B quit=3B<br>>=3B <br>>=
=3B Hope this is helpful=2C<br>>=3B <br>>=3B Dan<br>>=3B <br>>=3B D=
aniel J. Nordlund<br>>=3B Washington State Department of Social and Healt=
h Services<br>>=3B Planning=2C Performance=2C and Accountability<br>>=
=3B Research and Data Analysis Division<br>>=3B Olympia=2C WA 98504-5204=
<br> <br /><hr />Windows 7: Simplify your PC. <a href=3D'http://=
www.microsoft.com/Windows/windows-7/default.aspx?ocid=3DPID24727::T:WLMTAGL=
:ON:WL:en-US:WWL_WIN_evergreen1:102009' target=3D'_new'>Learn more.</a></bo=
dy>
</html>=
--_9c06af7f-d735-4930-b67a-4fe5bd730e1e_--