C**********o 发帖数: 658 | 1 Hello,
I have a columns that contains value like “1/1/2011|5000,3/1/2013|8000”,
or "“1/1/2011|5000,3/1/2011|8000,4/5/2012|3456”, etc. The value can be
blank, or can be as much as 35 counts (identified by ",").
How can I do it in SAS to separate all these values by ","?
My purpose is to count how many values in each cell in this column (by ","),
and see how many months away of the last 2 value.
Thanks! | l****u 发帖数: 529 | | S******y 发帖数: 1123 | 3 In Python, it would be a one liner -
s='1/1/2011|5000,3/1/2011|8000,4/5/2012|3456'
print len(s.split(','))
---
欢迎浏览Python/R/Hadoop实战速成课网页-
http://plus.google.com/+statsGuyMITBBS/about | a*******y 发帖数: 105 | 4 data A;
input records $ 1-50;
cards;
1/1/2011|5000,3/1/2013|8000
1/1/2011|5000,3/1/2011|8000,4/5/2012|3456
;
run;
data B; set A;
count=countw(records, ',');
if count >= 2 then do;
month2=input(scan(scan(records, count, ','),1,'|'), MMDDYY10.);
month1=input(scan(scan(records, count-1, ','),1,'|'), MMDDYY10.);
monthbetween=intck('Month',month1, month2, 'C');
end;
run; | C**********o 发帖数: 658 | |
|