由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - A SAS problem
相关主题
in =option的一道题SAS 问题:关于比较variable 包子答谢
SAS base questionSAS sampling的问题
求教 SAS base 123 Q 16新人报道,兼问SAS data set的问题
哪个SAS function可以读这样的variablesas date variable exchange
再问一个SAS data select的问题关于substr一问, thanks!
求问一道SAS adv 题[合集] 初级傻问题,莫笑
请问base(123题)的第16题[合集] 请教一个sas问题
急请教一个sas 问题一个sas macro variable的问题。
相关话题的讨论汇总
话题: sas话题: compress话题: variable话题: use话题: them
进入Statistics版参与讨论
1 (共1页)
m******m
发帖数: 445
1
I have a char variable in a large dataset, containing different type of
characters. I want to keep only alphabet and number in this variable. At
first I want to use compress function but the point is that I don't know all
the other character in the variable. I can check several observations and
get some of them but don't know how to do a thorough test to get all of them
.
Is there anyway to do it in SAS? thanks!
p********a
发帖数: 5352
2
data a;
b='sada9>a876&&*gh##98';
output;
b='sada<9>a876&*gh##98';
output;
run;
data c;
length b1 $20.;
set a;
b1='';
do i=1 to length(b);
if anyalnum(b,i)=i then b1=cats(b1,substr(b,i,1));
end;
drop b i;
run;
proc print;run;
t*a
发帖数: 117
3
if you have 9.1, you can use COMPRESS function with modifiers.
in your case, you can simply use:
new =compress(old,,'adk'); /* A for letters (upper and lower),
D for numbers,
K for keep)*/
http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a000212246.htm

all
them

【在 m******m 的大作中提到】
: I have a char variable in a large dataset, containing different type of
: characters. I want to keep only alphabet and number in this variable. At
: first I want to use compress function but the point is that I don't know all
: the other character in the variable. I can check several observations and
: get some of them but don't know how to do a thorough test to get all of them
: .
: Is there anyway to do it in SAS? thanks!

m******m
发帖数: 445
4
Yes I just figure out this. I use 9.1.3 but I always use v8 online help.
That's why I couldn't find this new modifier. Thanks!

【在 t*a 的大作中提到】
: if you have 9.1, you can use COMPRESS function with modifiers.
: in your case, you can simply use:
: new =compress(old,,'adk'); /* A for letters (upper and lower),
: D for numbers,
: K for keep)*/
: http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a000212246.htm
:
: all
: them

m******m
发帖数: 445
5
thanks! good to learn some new functions.

【在 p********a 的大作中提到】
: data a;
: b='sada9>a876&&*gh##98';
: output;
: b='sada<9>a876&*gh##98';
: output;
: run;
: data c;
: length b1 $20.;
: set a;
: b1='';

1 (共1页)
进入Statistics版参与讨论
相关主题
一个sas macro variable的问题。再问一个SAS data select的问题
How to add a variable showing observations from 1 to 1000求问一道SAS adv 题
sas新手求救,合并databases请问base(123题)的第16题
一个用R 进行data preparation的问题急请教一个sas 问题
in =option的一道题SAS 问题:关于比较variable 包子答谢
SAS base questionSAS sampling的问题
求教 SAS base 123 Q 16新人报道,兼问SAS data set的问题
哪个SAS function可以读这样的variablesas date variable exchange
相关话题的讨论汇总
话题: sas话题: compress话题: variable话题: use话题: them