LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2009, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
Comments: To: dfernandez@cst.cat
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>&gt=3B Date: Thu=2C 29 Oct 2009 12:44:58 +0100<br>&gt= =3B From: DFernandez@CST.CAT<br>&gt=3B Subject: Re: [SAS-L] macro varlist n= eeds to be separated by quotes and commas<br>&gt=3B To: SAS-L@= LISTSERV.UGA.EDU<br>&gt=3B <br>&gt=3B Hi Ruslan=2C<br>&gt=3B <br>&gt=3B Thi= s way will be incorrect=2C you are forgetting the first observation.<br>&gt= =3B If variable contains two observation=2C example: JOHN=2CDORIS<br>&gt=3B= the 'separated by '"=2C"' will output:<br>&gt=3B <br>&gt=3B JOHN"=2C"DORIS= <br>&gt=3B <br>&gt=3B Daniel Fernandez.<br>&gt=3B Barcelona<br>&gt=3B <br>&= gt=3B <br>&gt=3B <br>&gt=3B <br>&gt=3B -----Mensaje original-----<br>&gt=3B= De: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] En nombre de Ruslan = Kirhizau<br>&gt=3B Enviado el: dijous=2C 29 / octubre / 2009 12:38<br>&gt= =3B Para: SAS-L@LISTSERV.UGA.EDU<br>&gt=3B Asunto: Re: macro varlist needs = to be separated by quotes and commas<br>&gt=3B <br>&gt=3B separated by '"= =2C"' . Leading and trailing quotes can be added when you use this list<br>= &gt=3B Sent on the Now Network from my Sprint=AE BlackBerry<br>&gt=3B <br>&= gt=3B -----Original Message-----<br>&gt=3B From: "Nordlund=2C Dan (DSHS/RDA= )" &lt=3BNordlDJ@DSHS.WA.GOV&gt=3B<br>&gt=3B Date: Wed=2C 28 Oct 20= 09 17:38:59<br>&gt=3B To: &lt=3BSAS-L@LISTSERV.UGA.EDU&gt=3B<br>&gt=3B Subj= ect: Re: macro varlist needs to be separated by quotes and commas<br>&= gt=3B <br>&gt=3B &gt=3B -----Original Message-----<br>&gt=3B &gt=3B From: S= AS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of D T<br>&gt=3B= &gt=3B Sent: Wednesday=2C October 28=2C 2009 5:18 PM<br>&gt=3B &gt=3B To: = SAS-L@LISTSERV.UGA.EDU<br>&gt=3B &gt=3B Subject: macro varlist needs to be = separated by quotes and commas<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B I have a l= ist of character variables that needs to be used in<br>&gt=3B &gt=3B a subs= equent step to extract more detail linked to the IDs in the list. The IDs<b= r>&gt=3B &gt=3B contain numbers and letters=2C and need to be quoted when u= sed. How can that be<br>&gt=3B &gt=3B done? Can the quotes be added when th= e list is created? Or can the quotes be<br>&gt=3B &gt=3B added when<br>&gt= =3B &gt=3B I evoke the list in the second step?<br>&gt=3B &gt=3B<br>&gt=3B = &gt=3B<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B Here is what I have so far:<br>&gt= =3B &gt=3B<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B proc sql<br>&= gt=3B &gt=3B noprint=3B<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B select<br>&gt=3B = &gt=3B distinct pdid=2C id2<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B into<br>&gt= =3B &gt=3B :plist separated by '=2C'=2C<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B := idlist<br>&gt=3B &gt=3B separated by '=2C'<br>&gt=3B &gt=3B<br>&gt=3B &gt= =3B from madeup<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B where<br>&gt=3B &gt=3B pd= id in ('899G'=2C'8995'=2C'5902'=2C'344D'=2C'8997')=3B<br>&gt=3B &gt=3B<br>&= gt=3B &gt=3B quit=3B<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B<br>= &gt=3B &gt=3B %put<br>&gt=3B &gt=3B &amp=3Bplist &amp=3Bidlist=3B<br>&gt=3B= &gt=3B<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B proc sql=3B<br>&= gt=3B &gt=3B<br>&gt=3B &gt=3B select<br>&gt=3B &gt=3B pdid=2C<br>&gt=3B &gt= =3B<br>&gt=3B &gt=3B id2=2C<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B demo1=2C<br>&= gt=3B &gt=3B<br>&gt=3B &gt=3B demo2=2C<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B de= mo3<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B from demodat<br>&gt=3B &gt=3B<br>&gt= =3B &gt=3B where<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B pdid<br>&gt=3B &gt=3B<br= >&gt=3B &gt=3B in (&amp=3Bplist)<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B<br>&gt= =3B &gt=3B and<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B id2 in<br>&gt=3B &gt=3B (&= amp=3Bidlist)<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B and<br>&gt=3B &gt=3B<br>&gt= =3B &gt=3B year(date)<br>&gt=3B &gt=3B in (2006)=3B<br>&gt=3B &gt=3B<br>&gt= =3B &gt=3B quit=3B<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B<br>&g= t=3B &gt=3B This<br>&gt=3B &gt=3B does not work because both sets of IDs ne= ed to be quoted in addition to being<br>&gt=3B &gt=3B separated by commas.<= br>&gt=3B &gt=3B<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B Your he= lp is appreciated. Thanks!<br>&gt=3B &gt=3B<br>&gt=3B &gt=3B DT.<br>&gt=3B = &gt=3B<br>&gt=3B <br>&gt=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>&gt=3B <br>&gt=3B = proc sql =3B<br>&gt=3B select quote(pdid) into: plist separated by '=2C'<= br>&gt=3B from madeup<br>&gt=3B =3B<br>&gt=3B quit=3B<br>&gt=3B <br>&gt= =3B Hope this is helpful=2C<br>&gt=3B <br>&gt=3B Dan<br>&gt=3B <br>&gt=3B D= aniel J. Nordlund<br>&gt=3B Washington State Department of Social and Healt= h Services<br>&gt=3B Planning=2C Performance=2C and Accountability<br>&gt= =3B Research and Data Analysis Division<br>&gt=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_--


Back to: Top of message | Previous page | Main SAS-L page