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

Another way of achieving the goal in a single step is using CALL VNEXT instead of the dual arrays (as suggested by @mkeintz on SAS-L) coupled with CALL EXECUTE:

data have ;                                     
  input ID :$3. X_1 X_2 X_3 Y_1 Y_2 W_3  :$1. ; 
  cards ;                                       
ID1 1 2 3 4 5 6 C                               
ID2 2 3 4 5 6 7 D                               
run ;                                           
                                                
data _null_ ;                                   
  set have (obs = 1) ;                          
  length _vn $ 32 ;                              
  call execute ("data want; set have(keep=") ;  
  do until (cmiss (_vn)) ;                      
    call vnext (_vn) ;                          
    if find (_vn, "3") then call execute (_vn) ;
  end ;                                         
  call execute ("); run;") ;                    
run ;                                           

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
  • 4018 views
  • 9 likes
  • 6 in conversation