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.

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 1834 views
  • 5 likes
  • 4 in conversation