BookmarkSubscribeRSS Feed
ihlayyel
Fluorite | Level 6

I would like to split the value of history1 so that: coustmer id account_type history1 
1 13 """STDSTD058030""" 
1 3 """STDSTDSTDXXXSTDXXXS""" 
2 4 """STDSTDSTDXXXSTDXXX""" 
2 3 """000""" 
2 10 """000000000""" 
3 53 """STDXXX""" 
3 10 """000001""" 

"""STDxxxxxx000090030045STD"""

...would be like :

"""STD, xxx , xxx , 000,   090 , 030, 045, STD"""

I then want to count how many ac_num that have (value > 030) for each string and the min number of values before 030 appears. Maybe something like this:

select customer_No          
  count(ac_num)    
   if there is value in (type 1 ) > 030    else 0  
   count min number of values <30
   from Test_Data   
   group by customer_no  
    ;quit;

The output would be something like:

cosutmer_no  ,   count_ac_num ,   values   
1                   2            4    
2                   1            5   
3                   0            0   

 

1 REPLY 1
ChrisNZ
Tourmaline | Level 20

1- Most people will not download an MS Office file.

   Post the data as a data step (and check that it runs fine)

2- How do you know where to split the string? Your example splits every 3 characters. Is that the logic to use?

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 1 reply
  • 1317 views
  • 0 likes
  • 2 in conversation