LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) 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 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
Comments: To: dfernandez@cst.cat
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>&gt=3B Date: Thu=2C 29 Oct 2009 12:35:07 +0100<br>&gt=3B From:= DFernandez@CST.CAT<br>&gt=3B Subject: Re: [SAS-L] SUSPECT: RE: [SAS-L]: ma= cro varlist needs to be separated by quotes and c= ommas<br>&gt=3B To: SAS-L@LISTSERV.UGA.EDU<br>&gt=3B <br>&gt=3B Yeah!<br>&g= t=3B <br>&gt=3B <br>&gt=3B <br>&gt=3B Quote/2 function!! NOT REAL=2C I am= just kidding... TRY THIS:<br>&gt=3B <br>&gt=3B <br>&gt=3B <br>&gt=3B "'"|= |strip(yourvarname)||"'"<br>&gt=3B <br>&gt=3B <br>&gt=3B <br>&gt=3B proc s= ql noprint=3B<br>&gt=3B <br>&gt=3B select distinct "'"||strip(name)||"'"=2C= <br>&gt=3B <br>&gt=3B "'"||strip(sex)||"'"<br>&gt= =3B <br>&gt=3B into:namelist separated by '=2C'= =2C<br>&gt=3B <br>&gt=3B :sexlist separated by '=2C'<= br>&gt=3B <br>&gt=3B from sashelp.class<br>&gt=3B <br>&gt=3B where<br>&gt= =3B <br>&gt=3B upcase(name) in ('MARY'=2C'THOMAS')=3B<br>&gt=3B <br>&gt=3B = quit=3B<br>&gt=3B <br>&gt=3B <br>&gt=3B <br>&gt=3B %put &amp=3Bnamelist = &amp=3Bsexlist=3B.<br>&gt=3B <br>&gt=3B <br>&gt=3B <br>&gt=3B Daniel F= ernandez.<br>&gt=3B BArcelona<br>&gt=3B <br>&gt=3B <br>&gt=3B <br>&gt=3B = <br>&gt=3B <br>&gt=3B <br>&gt=3B <br>&gt=3B <br>&gt=3B <br>&gt=3B <br>&g= t=3B <br>&gt=3B ________________________________<br>&gt=3B <br>&gt=3B De: D= T [mailto:sasandstats@live.com] <br>&gt=3B Enviado el: dijous=2C 29 / octu= bre / 2009 12:22<br>&gt=3B Para: Fern=E1ndez Rodr=EDguez=2C Dani=3B sas-l@l= istserv.uga.edu<br>&gt=3B Asunto: SUSPECT: RE: [SAS-L]: macro varlist needs= to be separated by quotes and commas<br>&gt=3B <br>&gt=3B <br>&gt=3B <br>= &gt=3B Thanks=2C Dan and Daniel.<br>&gt=3B <br>&gt=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>&gt=3B <br>&gt=3B DT.<br>&gt= =3B <br>&gt=3B &gt=3B Subject: RE: SUSPECT: macro varlist needs to be separ= ated by quotes and commas<br>&gt=3B &gt=3B Date: Thu=2C 29 Oct 2009 10:50:3= 2 +0100<br>&gt=3B &gt=3B From: DFernandez@CST.CAT<br>&gt=3B &gt=3B To: sasa= ndstats@LIVE.COM=3B SAS-L@LISTSERV.UGA.EDU<br>&gt=3B &gt=3B <br>&gt=3B &gt= =3B Hi=2C<br>&gt=3B &gt=3B <br>&gt=3B &gt=3B Yeah you can use Quote functio= n inside the SQL select like this:<br>&gt=3B &gt=3B <br>&gt=3B &gt=3B proc = sql noprint=3B<br>&gt=3B &gt=3B select distinct quote(strip(name))=2C<br>&g= t=3B &gt=3B quote(strip(sex))<br>&gt=3B &gt=3B into:namelist separated by '= =2C'=2C<br>&gt=3B &gt=3B :sexlist separated by '=2C'<br>&gt=3B &gt=3B from = sashelp.class<br>&gt=3B &gt=3B where<br>&gt=3B &gt=3B upcase(name) in ('MAR= Y'=2C'THOMAS')=3B<br>&gt=3B &gt=3B quit=3B<br>&gt=3B &gt=3B <br>&gt=3B &gt= =3B %put &amp=3Bnamelist &amp=3Bsexlist=3B<br>&gt=3B &gt=3B <br>&gt=3B &gt= =3B It would be good you use Strip function to not pass blanks to macro var= iable.<br>&gt=3B &gt=3B <br>&gt=3B &gt=3B Daniel Fernandez.<br>&gt=3B &gt= =3B BArcelona<br>&gt=3B &gt=3B <br>&gt=3B &gt=3B -----Mensaje original-----= <br>&gt=3B &gt=3B De: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] En = nombre de D T<br>&gt=3B &gt=3B Enviado el: dijous=2C 29 / octubre / 2009 01= :18<br>&gt=3B &gt=3B Para: SAS-L@LISTSERV.UGA.EDU<br>&gt=3B &gt=3B Asunto: = SUSPECT: macro varlist needs to be separated by quotes and commas<br>&gt=3B= &gt=3B <br>&gt=3B &gt=3B I have a list of character variables that needs t= o be used in<br>&gt=3B &gt=3B a subsequent step to extract more detail link= ed to the IDs in the list. The IDs<br>&gt=3B &gt=3B contain numbers and let= ters=2C and need to be quoted when used. How can that be<br>&gt=3B &gt=3B d= one? Can the quotes be added when the list is created? Or can the quotes be= 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 pdid 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=3Bpl= ist &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 demo3<br>&gt=3B &gt=3B <br>&gt=3B &g= t=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 &g= t=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>&gt=3B &gt=3B This<br>= &gt=3B &gt=3B does not work because both sets of IDs need to be quoted in a= ddition to being<br>&gt=3B &gt=3B separated by commas. <br>&gt=3B &gt=3B <b= r>&gt=3B &gt=3B <br>&gt=3B &gt=3B <br>&gt=3B &gt=3B Your help is appreciate= d. Thanks!<br>&gt=3B &gt=3B <br>&gt=3B &gt=3B DT.<br>&gt=3B &gt=3B <br>&gt= =3B &gt=3B <br>&gt=3B &gt=3B ______________________________________________= ___________________<br>&gt=3B &gt=3B Windows 7: It helps you do more. Explo= re Windows 7.<br>&gt=3B &gt=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>&gt=3B <br>&gt=3B ________________________________<br>&gt=3B <br>&gt= =3B Windows 7: It works the way you want. Learn more. &lt=3Bhttp://www.micr= osoft.com/Windows/windows-7/default.aspx?ocid=3DPID24727::T:WLMTAGL:ON:WL:e= n-US:WWL_WIN_evergreen2:102009&gt=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_--


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