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- 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?
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.