BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hashman
Ammonite | Level 13

@mkeintz:

Mark, I may be overlooking something, but to my mind the logic is no different in principle from the following (not using FIND/C function deliberately): 

data _null_ ;                                           
  array rec $1 r1-r8 ("1","2","1","3","4","3","5","2") ;
  length hash $ 8 ;                                     
  do over rec ;                                         
    dup = . ;                                           
    do i = 1 to length (hash) ;                         
      if char (hash, i) = rec then dup = 1 ;            
    end ;                                               
    if not dup then hash = cats (hash, rec) ;           
  end ;                                                 
  put hash= ;                                           
run ;                                                   

Which results in:

hash=12345

The differences are that the real comparison condition is more complex than:

char (hash, i) = rec

and the hash table is used instead of the string HASH. So, basically, we're adding the hash items while eliminating the post-coming dupes in the process, so there's no need to delete anything from the hash when there're no more records.

 

Kind regards

Paul D.

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 15 replies
  • 1428 views
  • 5 likes
  • 4 in conversation