Date: Tue, 13 Mar 2012 10:35:29 -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: Programmatically matching parentheses. How?
Content-Type: text/plain; charset=ISO-8859-1
For the situation you describe I would look to another
parametrization. I'm not a fan of enumerated parameters DATA1=,DATA2=
but this might be a good place to use them. Plus I don't think the
users would find the enumerated parameters difficult to use, perhaps
On Tue, Mar 13, 2012 at 10:24 AM, Jim Groeneveld <email@example.com> wrote:
> Hi Data_Null,
> The information will be stored in a macro variable.
> I need it to specify only one dataset (with its options) at a time to PROC
> The options may drop or keep or rename variables or delete observations.
> And that in its turn is necessary for my cross reference macro CrossRef
> (see http://home.hccnet.nl/jim.groeneveld/software/SASmacro/CrossRef.zip).
> That macro in its turn is used to compare datasets with regard to
> dataset and variable attributes and main univariate statistics.
> The comparison in its turn is needed to decide about overlapping datasets
> or inconsistently named or coded variables.
> That in its turn is needed to clean up a large number of ad hoc datasets.
> And that finally is needed to improve the data management (with SAS).
> Regards - Jim.
> Jim Groeneveld, Netherlands
> Statistician/SAS consultant
> From: "Data _null_;" <firstname.lastname@example.org>
> To: Jim Groeneveld <email@example.com>
> Cc: SAS-L@listserv.uga.edu
> Sent: Tuesday, 13 March 2012, 15:53
> Subject: Re: Programmatically matching parentheses. How?
> I think you need to explain what you doing in more detail. Are you
> sure you need to separate the options from the data set names? What
> You may be focused on the wrong part of the problem.
> On 3/13/12, Jim Groeneveld <firstname.lastname@example.org> wrote:
>> Hi Ron,
>> Thanks. If no one comes with a complete solution I'll have to develop it
>> myself some of these days. I'll study your (and/or Toby's) suggestions.
>> not (yet) experienced in using regular expressions, but I would report any
>> solution that I find here on SAS-L.
>> Regards - Jim.
>> Jim Groeneveld, Netherlands
>> Statistician/SAS consultant
>> On Tue, 13 Mar 2012 12:18:56 +0000, Fehd, Ronald J. (CDC/OCOO/ITSO)
>> <rjf2@CDC.GOV> wrote:
>>>> From: Jim Groeneveld
>>>> Sent: Tuesday, March 13, 2012 5:16 AM
>>>> To: SAS-L@LISTSERV.UGA.EDU
>>>> Subject: Programmatically matching parentheses. How?
>>>> Hi friends,
>>>> I need your help with code that matches parentheses in a (macro)
>>>> value. (I will use such code in one or more macros.)
>>>> Problem: a text string containing dataset names and optionally dataset
>>>> options after each dataset name. I need to separate the options from the
>>>> name and so on for each name.
>>>> Just counting opening and closing parentheses isn't sufficient as they
>>>> can be
>>>> part of literal values (and names) as well. I can find the opening
>> but I
>>>> want to know the position of the closing one.
>>>> I tried to find solutions on the internet with Google, within SAS-L and
>>>> SAScommunity, but could not find any. Maybe I used the wrong search
>>>> So here goes my quest. Your suggestions are very much appreciated.
>>>> Regards - Jim.
>>>> Jim Groeneveld, Netherlands
>>>My suggestions are that you will have to parse your list with %substr
>>>list = data1 data2(dsoptions2) data3 data4(dsoptions4)
>>>pick the I-th data set name with
>>>%Let dsn = %scan(&List,&I,%str( )%str(());
>>>remove the dsn from the list with either tranwrd or
>>>%Let list = %substr(&List,%length(&dsn));
>>>check for existence of open paren:
>>>%if %substr(&List,1,1_ eq %str(() %then %do;
>>>*pick or remove;
>>>%Let dsoptions = %scan(&List,1,%index(&List,%str());
>>>%Let list = %sysfunc(tranwrd(&List,&dsoptions., ));
>>>Ron Fehd list processing maven
>>>of course %str(() or %str()) may not work exactlyas predicted.
>>>otherwise run it thru a data _Null_ step