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 (May 2012, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 4 May 2012 11:20:09 -0500
Reply-To:   "Data _null_;" <iebupdte@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Data _null_;" <iebupdte@GMAIL.COM>
Subject:   Re: My new favorite macro method to convert a space-delimited list to quoted csv
Comments:   To: toby dunn <tobydunn@hotmail.com>
In-Reply-To:   <BLU152-W20A13650945CBFDCFB52BDE2C0@phx.gbl>
Content-Type:   text/plain; charset=windows-1252

113 data _null_; 114 putlog ""Toby""; --- 22 200 ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, arrayname, #, (, +, /, //, ;, @, @@, OVERPRINT, _ALL_, _BLANKPAGE_, _ODS_, _PAGE_.

ERROR 200-322: The symbol is not recognized and will be ignored.

115 putlog """Toby"""; 116 run;

On 5/4/12, toby dunn <tobydunn@hotmail.com> wrote: > I saw that and cant figure out why Quote doubles the quotes unless its > seeing each ' in th eoriginal " as seperate and quotes them twice... > > Toby Dunn > > > If you get thrown from a horse, you have to get up and get back on, unless > you landed on a cactus; then you have to roll around and scream in pain. > > “Any idiot can face a crisis—it’s day to day living that wears you out” > ~ Anton Chekhov > > > >> Date: Fri, 4 May 2012 10:38:57 -0500 >> Subject: Re: My new favorite macro method to convert a space-delimited >> list to quoted csv >> From: iebupdte@gmail.com >> To: tobydunn@hotmail.com >> CC: SAS-L@listserv.uga.edu >> >> Don't you need to double the quoted double quotes? >> >> On 5/4/12, toby dunn <tobydunn@hotmail.com> wrote: >> > Ahhh Im tracking you now... I was looking at it like if the quote the >> > list >> > of words unless the word was already quoted... >> > which is a harder problem to solve than just quote every element in th >> > elist >> > regardless of whether it has quotes to start with or not.... >> > >> > >> > 10 %Let VarList = One "Two" Three ; >> > 11 %Let VarList = %SysFunc( PrxChange( s/([^\s]+)/"$1"/ , -1 , &VarList >> > ) >> > ) ; >> > 12 %Let VarList = %SysFunc( PrxChange( s/\s+/%Str(,)/ , -1 , &VarList ) >> > ) >> > ; >> > 13 %Put VarList = &VarList ; >> > VarList = "One",""Two"","Three" >> > >> > >> > >> > Toby Dunn >> > >> > >> > If you get thrown from a horse, you have to get up and get back on, >> > unless >> > you landed on a cactus; then you have to roll around and scream in >> > pain. >> > >> > “Any idiot can face a crisis—it’s day to day living that wears you out” >> > ~ Anton Chekhov >> > >> > >> > >> >> Date: Fri, 4 May 2012 09:49:56 -0500 >> >> From: iebupdte@GMAIL.COM >> >> Subject: Re: My new favorite macro method to convert a space-delimited >> >> list to quoted csv >> >> To: SAS-L@LISTSERV.UGA.EDU >> >> >> >> One of the words includes quotes but you did not preserve them. >> >> >> >> What is a word? >> >> >> >> On 5/4/12, toby dunn <tobydunn@hotmail.com> wrote: >> >> > You lost me soem where.... a well formed list is just a list of >> >> > words >> >> > seperated by a space.... >> >> > >> >> > Toby Dunn >> >> > >> >> > >> >> > If you get thrown from a horse, you have to get up and get back on, >> >> > unless >> >> > you landed on a cactus; then you have to roll around and scream in >> >> > pain. >> >> > >> >> > “Any idiot can face a crisis—it’s day to day living that wears you >> >> > out” >> >> > ~ Anton Chekhov >> >> > >> >> > >> >> > >> >> >> Date: Fri, 4 May 2012 09:39:06 -0500 >> >> >> Subject: Re: My new favorite macro method to convert a >> >> >> space-delimited >> >> >> list to quoted csv >> >> >> From: iebupdte@gmail.com >> >> >> To: tobydunn@hotmail.com >> >> >> CC: SAS-L@listserv.uga.edu >> >> >> >> >> >> Based on your notion of a well formed list of words shouldn’t you >> >> >> preserve the existing quotes. Where you end up with a word that >> >> >> looks >> >> >> like that returned by QUOTE function. >> >> >> >> >> >> 1 %put NOTE: %sysfunc(quote("Toby")); >> >> >> NOTE: """Toby""" >> >> >> >> >> >> >> >> >> On 5/4/12, toby dunn <tobydunn@hotmail.com> wrote: >> >> >> > 8 %Let VarList = One "Two" Three; >> >> >> > 39 %Let VarList = %SysFunc( PrxChange( >> >> >> > s/(?:\s+|\A)([a-z0-9]+)(?:\s+|\Z)/ >> >> >> > "$1" /i , -1 , &VarList >> >> >> > 39 ! ) ) ; >> >> >> > 40 %Let VaRList = %Sysfunc( PrxChange( s/\s+/%str(,)/ , -1 , >> >> >> > &VarList >> >> >> > ) >> >> >> > ) >> >> >> > ; >> >> >> > 41 %Put VarList = &VarList ; >> >> >> > VarList = "One","Two","Three" >> >> >> > >> >> >> > I used two calls mainly because I think its easier for me to read >> >> >> > and >> >> >> > understand....more of a divide and conquer the problem. >> >> >> > >> >> >> > OR >> >> >> > >> >> >> > >> >> >> > 2 %Let VarList = "One Two Three" ; >> >> >> > 43 %Let VaRList = %Sysfunc( PrxChange( s/\s+/"%str(,)"/ , -1 , >> >> >> > &VarList >> >> >> > ) >> >> >> > ) ; >> >> >> > 44 %Put VarList = &VarList ; >> >> >> > VarList = "One","Two","Three" >> >> >> > >> >> >> > >> >> >> > >> >> >> > Toby Dunn >> >> >> > >> >> >> > >> >> >> > If you get thrown from a horse, you have to get up and get back >> >> >> > on, >> >> >> > unless >> >> >> > you landed on a cactus; then you have to roll around and scream >> >> >> > in >> >> >> > pain. >> >> >> > >> >> >> > “Any idiot can face a crisis—it’s day to day living that wears >> >> >> > you >> >> >> > out” >> >> >> > ~ Anton Chekhov >> >> >> > >> >> >> > >> >> >> > >> >> >> >> Date: Fri, 4 May 2012 07:32:12 -0500 >> >> >> >> From: iebupdte@GMAIL.COM >> >> >> >> Subject: Re: My new favorite macro method to convert a >> >> >> >> space-delimited >> >> >> >> list to quoted csv >> >> >> >> To: SAS-L@LISTSERV.UGA.EDU >> >> >> >> >> >> >> >> I was going to ask what happens when KEYS_QC= contains a "SAS >> >> >> >> Variable >> >> >> >> List"? >> >> >> >> >> >> >> >> On 5/4/12, Tom Abernathy <tom.abernathy@gmail.com> wrote: >> >> >> >> > I still find using the individually named functions makes the >> >> >> >> > code >> >> >> >> > much >> >> >> >> > easier >> >> >> >> > to understand then PRX. >> >> >> >> > >> >> >> >> > %let keys_qc = "%sysfunc(tranwrd(&keys,%str( ),%str(",")))"; >> >> >> >> > %let keys_qc = >> >> >> >> > "%sysfunc(prxchange(s/\s+/%str(",")/,-1,&keys))"; >> >> >> >> > >> >> >> >> > On Thu, 3 May 2012 16:41:40 -0700, Sterling Paramore >> >> >> >> > <gnilrets@GMAIL.COM> >> >> >> >> > wrote: >> >> >> >> > >> >> >> >> >>15 %let keys = one two three; >> >> >> >> >>16 %let keys_qc = >> >> >> >> >>%unquote(%str(%")%sysfunc(prxchange(s/\s+/","/,-1,&keys))%str(%")); >> >> >> >> >>17 %put keys_qc = &keys_qc; >> >> >> >> >>keys_qc = "one","two","three" >> >> >> >> >> >> >> >> >> >> >> >> >> >> >>I avoided regular expressions for years. Now I love them! >> >> >> >> > >> >> >> > >> >> > >> > >


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