Splitting string variable into Multiple values then count column

Reply
Contributor
Posts: 25

Splitting string variable into Multiple values then count column

[ Edited ]

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   

 

PROC Star
Posts: 1,926

Re: Splitting string variable into Multiple values then count column

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?

Ask a Question
Discussion stats
  • 1 reply
  • 174 views
  • 0 likes
  • 2 in conversation