由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - [SAS] number of missing values for character vars
相关主题
问个sas编程的题请问如果用SAS 解决这个问题
help. sas macro很挑战的data transformation problem help
老问题如何产生missing table排序的问题,请问高手用SAS怎么做?
[合集] 请教Excel 操作 (Excel 2007)一个看着很简单sas的问题
关于missing value的问题how to combine characters and numric variable in "where" clause by SAS?urgent!
请问如何把一个数据里所有的变量名后面都加个v?thanks.怎么去掉一个CHARACTER VAR中的delimiters
问一个简单的SAS问题,多谢sas help, how to manipulating on the format value
sas coding problem(help!!!)SAS help : get macro variables as an string but not character variable.
相关话题的讨论汇总
话题: character话题: missing话题: proc话题: char话题: data
进入Statistics版参与讨论
1 (共1页)
D******n
发帖数: 2836
1
any easy proc to get the number of missing values of all the character
variables in a data set?
f*******e
发帖数: 51
2
data _null_;
set yourfile end=eof;
array char _character_ ;
do over char;
if char =" " then inx+1;
end;
if eof then call symput("total", left(inx));
%put &total;
run;
not sure if it's what u need or not
D******n
发帖数: 2836
3
what i want is the number of missing values for each var not a lump sum

【在 f*******e 的大作中提到】
: data _null_;
: set yourfile end=eof;
: array char _character_ ;
: do over char;
: if char =" " then inx+1;
: end;
: if eof then call symput("total", left(inx));
: %put &total;
: run;
: not sure if it's what u need or not

l*********s
发帖数: 5409
4
proc format;
value $miss " "="missing"
other="nomissing";
run;
proc freq data=temp;
tables charvar / missing;
format charvar $miss.;
run;
d*******o
发帖数: 493
5
这个码牛,可见多年功力,赞一个

【在 f*******e 的大作中提到】
: data _null_;
: set yourfile end=eof;
: array char _character_ ;
: do over char;
: if char =" " then inx+1;
: end;
: if eof then call symput("total", left(inx));
: %put &total;
: run;
: not sure if it's what u need or not

d*******o
发帖数: 493
6
proc sql;
select count(*)-count(var1) as num_missing1, count(*)-count(var2)as num_
missing2
from yourtable
;quit;
D******n
发帖数: 2836
7
if i have many , i have type them all? I am using the modified version of
littlebirds' solution
proc format;
value $miss " "="missing"
other="nomissing";
run;
proc freq data=temp;
tables _character_ / missing;
format _character_ $miss.;
run;
this is pretty close to what i want but it would be better if the tables are
aggregated into one.
s*r
发帖数: 2757
f*******e
发帖数: 51
9
想不出简单的。。。
proc sql noprint;
select name into : varlst separated by " "
from sashelp.vcolumn
where libname="yourlib" and memname="yourfile" and type="char";
quit;
%put &varlst;
proc transpose data=yourfile out=yourfile2;
var &varlst;
run;
data yourfile2;
set yourfile2;
array char _character_ ;
count=0;
do over char; if char =" " then count+1;
end;
keep _name_ count;
run;

【在 D******n 的大作中提到】
: any easy proc to get the number of missing values of all the character
: variables in a data set?

s******y
发帖数: 352
10
Code works only on SAS9.2.
data class;
set sashelp.class;
array temp $10. name sex cheight cweight cage;
cheight=cats(height);
cweight=cats(height);
cage=cats(age);
do over temp;
if ranuni(123456)<0.3 then call missing(temp);
end;
keep name sex c:;
run;
proc print;
run;
proc format;
value $miss " "="missing"
other="nomissing";
run;
proc tabulate data=class missing out=out;
class _character_;
table _all_,N;
format _character_ $miss.;
run;
data want(keep=var N rename=(N=miss));
set out;
array all
相关主题
请问如何把一个数据里所有的变量名后面都加个v?thanks.请问如果用SAS 解决这个问题
问一个简单的SAS问题,多谢很挑战的data transformation problem help
sas coding problem(help!!!)排序的问题,请问高手用SAS怎么做?
进入Statistics版参与讨论
D******n
发帖数: 2836
11
it doesnt work in my system.
o****o
发帖数: 8077
12
data _null_;
if _n_=1 then do;
length name $ 32;
declare hash h();
h.defineKey('name');
h.defineData('name', 'nmiss');
h.defineDone();
end;
set yourtable end=eof;
array _c{*} _character_;
if _n_=1 then do
j=1 to dim(_c); _x=vname(_c[j]); put _x=;
if dim(_c)=1 then stop;
end;

do j=2 to dim(_c);
if missing(_c[j]) then do;
if h.find(key:vname(_c[
D******n
发帖数: 2836
13
corrected some typos and it worked.
b******e
发帖数: 539
14
proc summary data=xxxx;
var _character_;
output out=test nmiss=;
run;
D******n
发帖数: 2836
15
This just simply doesn't work. nmiss is for numerics i guess.
b******e
发帖数: 539
16
that's right -- i only used on numeric values and thought it would be the
same for character values :(

【在 D******n 的大作中提到】
: This just simply doesn't work. nmiss is for numerics i guess.
b******e
发帖数: 539
17
then you can use a data step -- you need to know how many character
variables you have and their sequence in advance, which should be easy.
then:
assume you have 100 char variables:
data one (keep=count1-count100);
set xxx end=last;
retain count1-count100;
array char(*) _character_;
array count(100);
do i = 1 to dim(char);
count(i) = count(i) + missing(char(i));
end;
if last then output;
run;
1 (共1页)
进入Statistics版参与讨论
相关主题
SAS help : get macro variables as an string but not character variable.关于missing value的问题
哭死,用SAS作logistic regression的coefficients为何全部和proc reg得到的相反??请问如何把一个数据里所有的变量名后面都加个v?thanks.
一个很疑惑的SAS日期问题问一个简单的SAS问题,多谢
SAS data merge求助sas coding problem(help!!!)
问个sas编程的题请问如果用SAS 解决这个问题
help. sas macro很挑战的data transformation problem help
老问题如何产生missing table排序的问题,请问高手用SAS怎么做?
[合集] 请教Excel 操作 (Excel 2007)一个看着很简单sas的问题
相关话题的讨论汇总
话题: character话题: missing话题: proc话题: char话题: data