Date: Fri, 20 Jan 2012 14:26:11 -0500
Reply-To: oloolo <dynamicpanel@YAHOO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: oloolo <dynamicpanel@YAHOO.COM>
Subject: Re: Linked list without hash?
Content-Type: text/plain; charset=ISO-8859-1
Ya, using hash is not material difference than using an index data, so
instead of using hash.find() to locate and update key chain, you use a SET
KEY= statement.
check out my SCSUG paper Deep First Search in SAS
http://www.sas-programming.com/2008/11/deep-first-search-dfs-in-sas.html
On Fri, 20 Jan 2012 11:20:38 -0800, Huang, Ya <Ya.Huang@AMYLIN.COM> wrote:
>Thanks Joe,
>
>But isn’t SCL part of AF license? I’m afraid I don’t have AF anymore.
>Also, if I have to go SCL, maybe better off to do HASH instead?
>
>Ya
>
>From: Joe Whitehurst [mailto:joewhitehurst@gmail.com]
>Sent: Friday, January 20, 2012 10:40 AM
>To: Huang, Ya
>Cc: SAS-L@listserv.uga.edu
>Subject: Re: Linked list without hash?
>
>Ya,
>
>SAS has everything you said it lacks and has had these features since
about 1990. � The List construct might be easiest to understand if I were
to compare and contrast SAS Lists with SAS Arrays. Lists, like arrays, are
ordered collections of data. However, lists are more flexible than arrays
in many ways. For example, � lists are dynamic. Therefore, a program can
create a list only when and if it is needed. Lists grow and shrink to
accommodate the number of items or the size of items that you assign to
them. Also, a � List can contain items of differing data types including
other Lists or even itself. � And, yes, despite the lack of documentation,
Lists can be used in the context of a datastep. � � Here are just some of
the functions that deal with Lists:
>
>List
>“CLEARLIST” on page 265
>Clears the items from an SCL list without deleting the list and optionally
clears
>all sublist items
>“COMPARELIST” on page 274
>Compares two SCL lists
>“COPYLIST” on page 288
>Copies or merges the contents of an SCL list into an existing list or a
new list
>“CURLIST” on page 297
>Designates or reports the current result SCL list
>“DELITEM” on page 314
>Deletes an item from an SCL list
>“DELLIST” on page 315
>Deletes a list and optionally deletes all of its sublists
>“DELNITEM” on page 316
>Deletes a named item from an SCL list
>“DESCRIBE” on page 319
>Fills an SCL list with items of system information about a SAS table,
view, or
>catalog entry
>“ENVLIST” on page 355
>Returns the list identifier of an SCL environment list
>“FILLIST” on page 392
>Fills an SCL list with text and data
>“GETITEMC, GETITEML, GETITEMN, and GETITEMO” on page 430
>Returns a value that is identified by its position in an SCL list
>“GETLATTR” on page 432
>Returns the attributes of either an SCL list or an item in the list
>“GETNITEMC, GETNITEML, GETNITEMN, and GETNITEMO” on page 434
>Return a value identified by its item name in an SCL list
>“HASATTR” on page 448
>Reports whether an SCL list or a list item has a specified attribute
>“INSERTC, INSERTL, INSERTN, and INSERTO” on page 475
>Insert a value into an SCL list
>“ITEMTYPE” on page 491
>Reports the type of an item in an SCL list
>“LISTLEN” on page 517
>Reports the length of an SCL list
>“LVARLEVEL” on page 530
>Fills an SCL list with the unique values of a column from a SAS table
>
>On Fri, Jan 20, 2012 at 12:06 PM, Ya Huang <ya.huang@amylin.com> wrote:
>Hi there,
>
>Due to the lack of some popular data structure such as linked list,
>stack, queue etc., certain problem tend to be very hard for SAS to tackle.
>With � the introduction of HASH, things get easier, but learning curve is
>steep too. For the following sample, I would like to see if any
>traditional SAS technique is enough, without excessive using of macro.
>
>data x;
>input id1 $ id2 $ v $;
>cards;
>A B kkk
>D J dfs
>B A dft
>J K sdf
>A C sdf
>C A asf
>;
>
>In the sample above, AB is circular linked list, because A linked to B via
>Obs 1, � then B linked back to A via Obs3. AC is another example of
>circular link. D->J->K, on the other hand is open linked list. What I'm
>interested is to flag the records, so that circular linked records are
>grouped � together with flag of Cn, and open linked records are flagged as
>On etc.
>
>A B kkk � C1
>B A dft � C1
>D J dfs � O1
>J K sdf � O1
>A C sdf � C2
>C A asf � C2
>
>Note the chain may be very long, and the circle can be very big too (more
>than two nodes), I thought about using point in data step and loop through
>all the records, but felt it could be very inefficient, so hasn't try yet.
>
>Thanks
>
>Ya
|