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.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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