由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - 如何获得最后的几个数字
相关主题
another sas questionSAS BASE的一道题不明白,青椒
A SAS problem问个 sas 也许很简单的问题
a question about length assignmentsas date variable exchange
再问三个关于length的问题,谢谢关于substr一问, thanks!
a problem from sas base test#SAS BASE 问题,明天就考试了##
sas base 123 question 76 疑问SAS BASE 快疯掉了!!!!
哪个SAS function可以读这样的variable百思不得其解的sas base 123题第76题
如何找到两个相同character在一个string中的位置?一个用R 进行data preparation的问题
相关话题的讨论汇总
话题: anydigit话题: substr话题: length话题: abcde1000话题: strip
进入Statistics版参与讨论
1 (共1页)
a****g
发帖数: 8131
1
我有一些character
都有如下模式
abcde0
abcde5
abcde10
abcde1000
所以我打算用substr, 第一个位置参数是确定的
这种情况怎么解决比较好
thanks
w*******9
发帖数: 1433
2
Length function?
a****g
发帖数: 8131
3
the length is the same since it was defined

【在 w*******9 的大作中提到】
: Length function?
k*******a
发帖数: 772
4
把tailing 空格去掉
试试strip 或者trim
比如 length(trim(x))
P****D
发帖数: 11146
5
length function返回的是真实长度。你担心的那个是lengthm,返回declared长度。
http://www.notecolon.info/2011/06/note-length-functions-somethi

【在 a****g 的大作中提到】
: the length is the same since it was defined
a****g
发帖数: 8131
6
thank you
will try it again. i tried it but did not work. I might have made some other
mistakes.

【在 P****D 的大作中提到】
: length function返回的是真实长度。你担心的那个是lengthm,返回declared长度。
: http://www.notecolon.info/2011/06/note-length-functions-somethi

a****g
发帖数: 8131
7
thanks
tried this but not working
will check again

【在 k*******a 的大作中提到】
: 把tailing 空格去掉
: 试试strip 或者trim
: 比如 length(trim(x))

P****D
发帖数: 11146
8
不客气。你肯定是哪里写错了。substr配合length,我天天用呢。

other

【在 a****g 的大作中提到】
: thank you
: will try it again. i tried it but did not work. I might have made some other
: mistakes.

d********i
发帖数: 193
9
use perl regular expression
d******9
发帖数: 404
10
Please google and try to use these functions:
Anydigit, anyalpha etc.
Bao Zi, please
相关主题
sas base 123 question 76 疑问SAS BASE的一道题不明白,青椒
哪个SAS function可以读这样的variable问个 sas 也许很简单的问题
如何找到两个相同character在一个string中的位置?sas date variable exchange
进入Statistics版参与讨论
l******m
发帖数: 111
11
楼上正解
data _null_;
a='abcde0';
b='abcde5';
c='abcde10';
d='abcde1000';
a1=substr(a,anydigit(a),length(strip(a))-anydigit(a)+1);
b1=substr(b,anydigit(b),length(strip(b))-anydigit(b)+1);
c1=substr(c,anydigit(c),length(strip(c))-anydigit(c)+1);
d1=substr(d,anydigit(d),length(strip(d))-anydigit(d)+1);
put a= b= c= d= a1= b1= c1= d1=;
run;
a***d
发帖数: 336
12
如果第一个位置参数是确定的直接用substr(yourstr,pos)就可以了吧。

【在 a****g 的大作中提到】
: 我有一些character
: 都有如下模式
: abcde0
: abcde5
: abcde10
: abcde1000
: 所以我打算用substr, 第一个位置参数是确定的
: 这种情况怎么解决比较好
: thanks

j*****7
发帖数: 4348
13
name_new = compress(name, 'abcde');

【在 a****g 的大作中提到】
: 我有一些character
: 都有如下模式
: abcde0
: abcde5
: abcde10
: abcde1000
: 所以我打算用substr, 第一个位置参数是确定的
: 这种情况怎么解决比较好
: thanks

S******y
发帖数: 1123
14
If you are interesting in doing that in Python RE -
>>> m = re.search(r'\d+$', 'abcde1000')
>>> int(m.group())
1000
A*******s
发帖数: 3942
15
second this.
just spend several hrs on learning some regex basics, lz would find out it
could save u a lot of efforts...

【在 d********i 的大作中提到】
: use perl regular expression
I*****a
发帖数: 5425
16
substr(a, 6, nchar(a)) ?


【在 a****g 的大作中提到】
: 我有一些character
: 都有如下模式
: abcde0
: abcde5
: abcde10
: abcde1000
: 所以我打算用substr, 第一个位置参数是确定的
: 这种情况怎么解决比较好
: thanks

i******g
发帖数: 73
17
in SAS there is a reverse function I believe, ABCDE becomes EDCBA
reverse it, take the numbers, then reverse the results again, then get what
you need.

【在 a****g 的大作中提到】
: 我有一些character
: 都有如下模式
: abcde0
: abcde5
: abcde10
: abcde1000
: 所以我打算用substr, 第一个位置参数是确定的
: 这种情况怎么解决比较好
: thanks

k*z
发帖数: 4704
18
compress(var,'abcdefghijklmnopqrstuvwxyz',"a or e")

【在 a****g 的大作中提到】
: 我有一些character
: 都有如下模式
: abcde0
: abcde5
: abcde10
: abcde1000
: 所以我打算用substr, 第一个位置参数是确定的
: 这种情况怎么解决比较好
: thanks

1 (共1页)
进入Statistics版参与讨论
相关主题
一个用R 进行data preparation的问题a problem from sas base test
问一个sas format问题sas base 123 question 76 疑问
SAS Macro Function哪个SAS function可以读这样的variable
Another SAS perl question如何找到两个相同character在一个string中的位置?
another sas questionSAS BASE的一道题不明白,青椒
A SAS problem问个 sas 也许很简单的问题
a question about length assignmentsas date variable exchange
再问三个关于length的问题,谢谢关于substr一问, thanks!
相关话题的讨论汇总
话题: anydigit话题: substr话题: length话题: abcde1000话题: strip