由买买提看人间百态

topics

全部话题 - 话题: noprint
1 2 下页 末页 (共2页)
R******d
发帖数: 1436
1
不知道我理解对了不
data test;
input var1 $ var2 var3;
datalines;
a . 1.1
a 5 .
a 6 .
b 5 0
b 5 0
b 7 .
;
run;
proc sql noprint;select distinct var1 into:vars separated by ' ' from test;quit;
proc sql noprint;select count(distinct var1) into:nvar from test; quit;
%macro test;
%do i=1 %to &nvar;
proc sql noprint;
create table tmp as
select *,max(var3>0) as index,max(var3) as max from test where var1="%qscan(&vars,&i,' ')";
quit;
proc append base
R******d
发帖数: 1436
2
来自主题: Statistics版 - 请教个概率计算的问题
是的,非常感谢,我看懂了。写了个脚本去抽样,和公式给的结果很接近。
%macro simu(number, ratio, runs);
data data;
do n=1 to &number.;
output;
end;
run;
proc surveyselect data=data out=sample method=srs samprate=&ratio. rep=&runs
. noprint;
run;
proc summary data=sample nway noprint;
class n;
output out=counts;
run;
data result(drop=_type_);
merge data counts;
by n;
if _freq_=. then _freq_=0;
run;
proc sql noprint;
create table summary as
select sum(_freq_^=0)/&number. as rate, mean(_freq_) as mean, &number as
number, &ratio as ra... 阅读全帖
z**********i
发帖数: 12276
3
来自主题: Statistics版 - sas问题
问个初级的问题,产生的DATA,如何形成一个DATA SET呢?
自己找了老半天,也没弄明白,原来的DATA SET ONE,并没有变化.
非常感谢!!
另外,我的文件很大,要半天才行.
我加了个NOPRINT,就好了,目前的问题是如何调用新的DATA SET.
proc sql NOPRINT;
s********p
发帖数: 637
4
%let outvar=;
%macro cal_var_nums(indata);
proc contents data=&indata out=out noprint; run;
proc sql noprint;
select count(name) into :outvar
from out
;
quit;
%mend;
%cal_var_nums(model(obs=0));
%put "Total variable:" &outvar;
%cal_var_nums(model(obs=0 keep=_NUMERIC_ ));
%put "Num variable:" &outvar;
%cal_var_nums(model(obs=0 keep=_CHARACTER_ ));
%put "Char variable:" &outvar;
o****o
发帖数: 8077
5
data one;
input id x y Z A B C;
datalines;
1 1 0 1 1 1 1
2 0 1 1 1 1 1
3 1 1 1 1 1 1
4 0 0 1 1 1 1
5 1 0 0 0 0 0
;
run;
proc contents data=one out=onevars(keep=name varnum where=(upcase(name)^='
ID')) noprint; run;
data _null_;
set onevars end=eof;
if _n_=1 then call execute('proc freq data=one noprint;');
call execute('table '||name||' /out'||compress('=_'||name)||'(where=('|
|name||'=1));');
if eof then call execute ('run;');
run;
options source ;
data _null_;
c
o****o
发帖数: 8077
6
来自主题: Statistics版 - how to set a global constant in sas?
这就是无数programmer痛恨SAS的原因
不过你可以用
proc sql noprint;
select b into :b1-:b3
from yourvectordataset
;
quit;
then use &b3 to call this one element
example:
************************;
data _vector;
do b=1 to 3; output; end;
run;
proc sql noprint;
select b into :b1-:b3
from _vector
;
quit;
%put &b3;
s*******d
发帖数: 132
7
来自主题: Statistics版 - 一个关于SAS macro的问题
我也问过同样的问题。有牛人oloolo 解答。。
proc sql noprint;
select b into :b1-:b3
from yourvectordataset
;
quit;
then use &b3 to call this one element
example:
************************;
data _vector;
do b=1 to 3; output; end;
run;
proc sql noprint;
select b into :b1-:b3
from _vector
;
quit;
%put &b3;
w*****m
发帖数: 414
8
来自主题: Statistics版 - 请教一个sas求和的问题
非常感谢 kirklanda,你的算法没有问题,完全解决了我的问题。
我以前是不知道怎么用 first.id then group=0 这一句命令。
另外讨论一个小问题,我需要把proc means的结果输出在另一个data set 里,所以我把
你的命令
改成
proc means data=a noprint;
by id group;
var x;
output
out=outdata
mean=x
median=x_m
std=x_std
sum=x_sum;
run;
结果没有问题,可奇怪的是,当我在你的原程序中直接加 noprint的时候,sas报语法
错;我把它
用output命令些出来,结果出错,我然后把class 改为 by,运行就没问题了。
没有大的变化,只是很奇怪SAS为什么这样?另给其他留个借鉴,希望有所帮助。

data a;
set a;
by id;
if first.id then group=0;
if sequence=1 then group+1;
proc print data=a;run;
proc means data=a sum mean... 阅读全帖
w*****m
发帖数: 414
9
来自主题: Statistics版 - 请教一个sas求和的问题
丸子的这个算法有个小问题。如果你看我的原始数据描述就会发现,每一个id中的
sequence有时候
是重复的。比如说,对于同一个id,事件在2000年发生一次,sequence=1, 2001没有发
生,跳
过,2002年发生一次,sequence=1, 2003年没发生,再跳过;2004年又发生一次,
sequence
还是=1,2005年没有发生,再次跳过。
对于这个id,sequence=1出现三次。丸子直接做
proc univariate data=sum noprint;
class id sequence;
就有问题了。

proc sort data=sum;
by id sequence;
run;
proc univariate data=sum noprint;
class id sequence;
var x;
output out=report sum=sum mean=mean median=median std=std;
run;
T*******I
发帖数: 5138
10
来自主题: Statistics版 - 两分法随机模拟试验SAS Code (Part I)
我准备接受goldmember的挑战公布Code。
SAS Code (Part I): Simulation for a Dichotomic Regression wirh Julious's Sample
我要公布的code仅仅是一个关于dichotomic regression simulation的SAS code。是我在4年多前写的。仅仅作了一点小小的更改。我的code写得很笨拙,但it runs good。请大家保存好你的500个随机样本。以备后用。
我将分段公布,这里是第一部分,data generation and random check.
这个例子是想要告诉大家,如果你的分析逻辑正确,根本不需要simulation。
正如我对goldmember说过,在接受这个挑战前,让我问大家几个问题:
如果总体中存在一个临界点,你认为样本临界模型一定在临界点处连续吗?如果你的回答是肯定的,你的哲学的或/和数学和/或统计学的逻辑基础是什么?然后再问问你自己,总体给了你连续性的保证吗?你可以在样本基础上假设总体的连续性吗?为什么?
大家回答了我的这几个问题后我再公布后面的正式算法... 阅读全帖
o****o
发帖数: 8077
11
来自主题: Statistics版 - 如何用SAS invert矩阵(没有IML)?
two approaches using PROC REG
1. ODS OUTPUT INVXPX=INVERSED;
PROC REG DATA=URDATA NOPRINT SINGULAR=1E-17;
MODEL Y = X1-X10 /I NOINT;
RUN;QUIT;
2. PROC REG DATA=URDATA2 NOPRINT OUTEST=INVERSED SINGULAR=1E-17;
MODEL I1-I10 = X1-X10 /NOINT;
RUN;QUIT;
check here:
http://www.sas-programming.com/2011/10/obtain-trace-of-projecti
baozi pls
p****u
发帖数: 1940
12
来自主题: Statistics版 - 请教一个sas 问题
PROC REG OUTest = c6_beta_std data=c5_readyToEstimate;
MODEL ret = vwretd / NOPRINT;
by key2;
RUN ;
--------------------------
PROC REG OUTest = c6_beta_std data=c5_readyToEstimate;
ID key2;
MODEL ret = vwretd / NOPRINT;
output out = c7_beta_std stdR = stdr;
by key2;
RUN ;
--------------------------
请教,我想输出residual standard deviation 和 系数 estimation。我想regression
by key2。最好能够输出到一个数据文件。第一个程序输出系数是在key2 group level
上估计的没问题。
但是第二个程序,输出是分开的(不喜欢)。而且用ID key2在c7_beta_std里面没有给
我想要的数据。这个程序现在的输出是每个数据点,而不是by... 阅读全帖
i****a
发帖数: 36252
13
来自主题: Database版 - Does anyone know FoxPro Report?
looking at the code do you mean open it in text editor? I opened it, it's
somewhat readable with a lot of noprintable characters. searched "use", or
the name of the database I know it's using, couldn't find anything

code
the
w****r
发帖数: 1046
14
来自主题: Statistics版 - 还是那个MACRO的问题
IF THEN 不起作用, 还是2个test都做. Thanks!!!
OPTIONS MACROGEN;
%MACRO TWO_SAMPLE (IN=, Y=, A=, ALPHA=);
PROC UNIVARIATE DATA=&IN NORMAL NOPRINT;
BY &A; VAR &Y;
OUTPUT OUT=ONE MEAN=MEANY STD=STDY N=N PROBN=PNORMAL;
DATA TWO;SET ONE;
IF PNORMAL>0.05 THEN DO;
PROC TTEST DATA=∈
CLASS &A; VAR &Y;
ODS OUTPUT TTESTS=TT;
DATA TT;SET TT;
IF _N_=2;
KEEP PROBT;
RENAME PROBT=PROB;
DATA THREE;IF _N_=1 THEN SET TT;SET TWO;
END;
IF PNORMAL ne 0.05 THEN DO;
p********a
发帖数: 5352
15
来自主题: Statistics版 - 还是那个MACRO的问题
修改了一下。你的CODE主要有几个问题
1. Data step and proc step 不能nested. Data step can't be nested in another
data step either.
2. %IF %THEN %END should be in open mode instead of data step
3. When you compare values in open mode, it has to be macro variables. (see
proc sql)
I still don't understand your last 4 data steps. There is no macro variables
at all. Why put them inside the macro.
OPTIONS MACROGEN;
%MACRO TWO_SAMPLE (IN=, Y=, A=, ALPHA=);
PROC UNIVARIATE DATA=&IN NORMAL NOPRINT;
BY &A; VAR &Y;
O
x*******u
发帖数: 500
16
来自主题: Statistics版 - 请教SAS 问题
只想出这个笨办法, 有没有更简单的
data a;
input x y z m n;
cards;
1 2 3 . 4
2 3 4 5 6
1 . 3 5 6
1 3 4 . .
;
run;
proc contents data=a out=out(keep=name); run;
proc sql noprint;
select name into: name separated by ' ' from out;
run;
proc transpose data=a out=b;
run;
data c; set b;
missnum=nmiss(of col1-col4);
run;
data d(where=(missnum=0))
e(where=(missnum>0));
set c;
run;
l****g
发帖数: 304
17
来自主题: Statistics版 - 请教macro的一个小程序,
请教,这段程序有错误吗?运行后没有任何结果?谢谢。
data one;
input status $ ;
cards;
serious
not
serious
not
serious
;
run;
%macro highway;
proc sql noprint;
%let numgrp=6;
select distinct status into : group1 - :group&numgrp from one;
quit;
%do i = 1 %to &numgrp ;
proc print data = one ;
where status = " &&group&i" ;
run;
%end;
%put &group1;
%mend;
%highway
a********r
发帖数: 2
18
来自主题: Statistics版 - 很弱的SAS合并数据问题
假设第一个数据名为a,第二个数据名为b,合并后的数据名为c
data a;
input x y;
cards;
1 1
2 2
3 3
;
run;
data b;
input z;
cards;
4
;
run;
proc sql noprint;
create table c as
select a.*,z from a,b;
quit;
z********n
发帖数: 710
19
proc freq data=x;
table var1;
by var2;
run;
I need to get a new dataset from this freq table with cumulative percent in
it.
How can I do it?
proc freq data=x;
table var1/noprint output=freq;
by var2;
run;
By running the previous code, I got percent not cumulative one.
The dataset is large. Thank you!!!
a********a
发帖数: 3176
20
Incompotent SAS worker soon to be performance reviewed, but got stuck with a
prolem - please help!
to run proc mean to get the value range by each catogories. The existing
variable lists are specified:
%let expla1 = age_c1 age_c2 age_c3 age_c4 age_c5
age_c6 age maxben1 maxben2 maxben;
%let bc1 = b b b b b b c b b c;

To be used in:
proc means data= f_data noprint;
var (first continous from EXPLA1, then 2nd, 3rd...continuous)
output o
o****o
发帖数: 8077
21
来自主题: Statistics版 - Help for freq subset
might be this way:
proc sql;
create table new as
select a.*
from yourdata as a
left join (select personid, count(*) as count
from yourdata(keep=personid)
group by personid
) as b
on a.personid=b.personid
where b.count>=3
;
quit;
or a SAS way
proc freq data=yourdata noprint;
table personid/out=_freq_(where=(count>=3)
keep=personid count
a********a
发帖数: 3176
22
I think I figured out one way to get the new list:
%Do I = 1 %to &NVar;
%let k=1;
%do %while (%Quote(%Scan(&&Var_&I, &K, %Str( ))) ^= );
%let newvar = %Quote(%Scan(&&Var_&I, &K, %Str( ))) ;
proc means data=&data noprint;
var &newvar;;
where taapart=1;
output out=&newvar min=min max=max;
run;
data &newvar;
length VARNAME $ 20.;
set &newvar;
VARNAME="&newvar";
proc append base=newvar data=&newvar force;
run;
%let k = %eval(&k + 1);
%let newvar = %scan(&&Var_&I,
d*******1
发帖数: 854
23
来自主题: Statistics版 - SAS问题求教
proc sql noprint;
select type, sum(value) as sum
from data group by type;
quit;
t*****l
发帖数: 11
24
来自主题: Statistics版 - 求教proc sql 问题
谢谢斑竹提醒, 用下面的code能够直接得到我想要得dataset, 不用带很多别的自动
variable
proc means data =aa noprint;
class id;
var v1 -- v3;
output out=bb(drop=_TYPE_ _FREQ_ where =(id ne .)) MEAN= ;
run;
回头再看看proc sql怎么做
o****o
发帖数: 8077
25
来自主题: Statistics版 - SAS help
data mydata;
input A B;
datalines;
1 1
1 1
1 3
1 3
1 5
1 23
2 4
2 4
2 6
2 6
2 12
2 22
;
run;
proc freq data=mydata noprint order=internal;
table A*B/out=order(drop=COUNT PERCENT);
run;
data order;
set order; by A;
retain Order;
if first.A then Order=1; else Order+1;
run;
proc sql;
create table outdata as
select a.*, b.Order
from mydata as a join order as b
on a.A=b.A & a.B=b.B
order by a.A, a.B
;
quit;
d*******1
发帖数: 854
26
来自主题: Statistics版 - 请教一个用SAS作DATA MERGE的问题
proc sql noprint;
create table data3 as
select a.id, a.var_1,b.var_2 from data1 a, data2 b
where a.id=b.id order by a.id,a.var_1,b.var_2;
quit;
g*******y
发帖数: 380
27
来自主题: Statistics版 - Modify the label of cdf plot in SAS?
Hi,all
I use the following code to generate the cdf plot:
proc univariate data=temp1 noprint;
var PPB;
by zone;
class type;
cdfplot PPB/overlay vref = 5 95
cvref = black
vreflabels = '5%' '95%' ;
run;
The goal it to get the overlapped plots of cumulative distribution frequency
of "PPB" in two different type by each zone.
Now I got those plots by zone, and the title is "cumulative distribution
function for PPB", how cou
h******e
发帖数: 1791
28
来自主题: Statistics版 - 现在是这么一个问题。
proc sql noprint;
select count(name) into :total;
from dataset_a
;
quit;
这个&total包含了空格,有什么办法在sql这步就将空格去掉?
l***a
发帖数: 12410
29
来自主题: Statistics版 - SAS help needed: baozi will be given
use "noprint" option when you can. or just use "ods listing close". the idea
is to not to print unnecessary output

I
needs
c*******o
发帖数: 8869
30
this just create a macro variable. a more direct approach is to create a
column in table directly....
proc sql noprint;
create table new as
select *, count(*) as obs_count from old;
quit;
o****o
发帖数: 8077
31
PROC FREQ
************************************;
proc freq data=one noprint;
table x/out=_xxxx(where=(x=1));
table y/out=_yyyy(where=(y=1));
run;
data _zzzz;
length var $ 1;
set _xxxx(in=_1 drop=x)
_yyyy(in=_2 drop=y);
if _1 then var='x';
else var='y';
run;
o****o
发帖数: 8077
32
you may want to avoid those loopy macros in practice;
*********************;
proc sql noprint;
select cat('table ', compress(name),' /out=', compress('_'||name), '(
where=(',compress(name),'=1));')
into :tablestmt separated by ' '
from onevars
;
select (compress('_'||name)||'(in=_'||name||'drop='||name||')')
into :setstmt separated by ' '
from onevars
;
select ('if '||compress('_'||name)||'=1 then varname='||compress('"'||
name||'"')||'
p*****0
发帖数: 3104
33
来自主题: Statistics版 - SAS问题请教
我现在有个数据有几百个columns,有数字也有char,其中数字column有4中形式的
missing variables: -444, -555, -666, -999.我要把他们全部替换成 '.'
我写了下面这个macro,但是不work。 在%if后的macrovariable不解析成column name,并且代表在此column里的各个数值
。 哪位帮忙给我看看应该如何处理,谢谢。
%macro replace(data);
%* Output the variable names and positions of data;
proc contents data=&data
position
noprint
out=var (keep=name varnum type);
run;
%* Preserve numeric variables only;
data var; set var;
where type=1;
run;
%* create global macro variables;
data _null_;
c*******o
发帖数: 8869
34
来自主题: Statistics版 - 请教一个SAS问题
data yourdata;
set yourdata;
if sum of (p1-p10)=10 and good then yes=1;
else yes=0;
run;
proc sort data=yourdata; by good yes; run;
proc transpose data=yourdata out=tyourdata name=p;
by good yes;
var P1-P10;
run;
proc sql noprint;
create table result as
select good, yes, p, count(*) as count
from tyourdata group by good, yes, p
quit;
R******d
发帖数: 1436
35
来自主题: Statistics版 - 问一个proc sql的问题,多谢
两个表。一个10000多行(a),第二个一个100000000行(b)。我用proc sql把这两连接起
来。好比:
proc sql noprint; create table c as
select table a.g1, a.g2, b.value from a left join b on a.g1=b.id1 and a.g2=b
.id2;
quit;
我发现value,也就是来自第二个表的数据是空的。检查了一下原始数据,应该是有的
。请问这是什么原因,是不是proc sql对处理的表有什么上限?
多谢了
s**********e
发帖数: 63
36
来自主题: Statistics版 - 问一个proc sql的问题,多谢
用 full join 会更好:
proc sql noprint;
create table c as
select table a.g1, a.g2, b.value from a full join b on a.g1=b.id1 and a.
g2=b.id2;
quit;
R******d
发帖数: 1436
37
回头看一下,前面写得有点脱裤子放屁
data test;
input var1 $ var2 var3;
datalines;
a . 1.1
a 5 .
a 6 .
b 5 0
b 5 0
b 7 .
;
run;
proc sql noprint;
create table result as
select *, max(var3) as max, max(var3)>0 as index from test group by var1;
quit;
data result;
set result;
if index=1 then var3=max;
run;
f*******e
发帖数: 51
38
想不出简单的。。。
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;
f*******e
发帖数: 51
39
来自主题: Statistics版 - 问个SAS 数据处理问题
mine
应该有更简单的
data test;
input name $ type;
cards;
A 1
A 1
A 2
B 1
C 1
C 3
C 2
;
run;
data temp;
length typeall $200;
retain typeall;
set test;
by name notsorted;
if first.name then typeall=strip(type);
else typeall=strip(typeall)||strip(type);
if last.name then output;
run;
proc sql noprint;
create table new as
select a.*, b.typeall
from test as a, temp as b
where a.name=b.name;
quit;
f*******e
发帖数: 51
40
来自主题: Statistics版 - 问一个data subset的问题
proc sql noprint;
create table c as
select b.*
from secondfile as b
where name in
(select distinct name from firstfile as a);
quit;
b******e
发帖数: 539
41
来自主题: Statistics版 - HELP!!!!!
the do loop in SAS is not the same as in other languages
besides, what do you want to do after it accumulates to 80%
anyway, here is something you can do:
first, get the total of A:
proc sql noprint;
select sum(A) into :total_A from new;
quit;
then get a data set that contains obs with accumulated A <= 80%:
data new;
set new;
retain C 0;
c = c + a;
if c <= 0.8*&total_a then output;
run;
g********d
发帖数: 2022
42
你那个方法我没看懂,详细说说?
可以这样生成一个macro v:
proc sql noprint;
select crdate into :crdate
from sashelp.vtable
where libname="" and memname="";
quit;
%put &crdate;
R******d
发帖数: 1436
43
来自主题: Statistics版 - 问个sas proc sql里数据格式的问题
proc sql noprint;
create table tmp as
select mean(value) as mean from data;
quit;
这个value是字符格式的,上面会报错。请问怎么方便的在proc sql中把字符格式转换
成数值? value+0在这里不顶用。
想不起来应该怎么处理了。
j******n
发帖数: 2206
44
another one:
PROC PLAN can produce a random permutation of the values 1-100000;
there will be no zero.
proc plan seed=1091883594;
factors r=100000 / noprint;
output out=r;
run;
proc print data=r(obs=100);
run;
proc print data=r(where=(r=0));
run;
R*********i
发帖数: 7643
45
来自主题: Statistics版 - sas 简单问题
Not "老手" or "前辈", just know some SAS coding.
Assume all your datasets are already in working directory, and "filenames"
is a .txt file.
data names;
infile "XXXX\XXXX\filenames";
input name $;
run;
proc sql noprint;
select name into: names seperatedby " "
from names;
quit;
data alldata;
set &names;
run;
There's a limit for the length of macro variable. So if your file names are
too long or you have more than several thousands files you will have to use
more than one macro variable to ... 阅读全帖
a****m
发帖数: 693
46
来自主题: Statistics版 - 请教一个sas问题
proc mi data=FitMiss noprint out=outmi seed=37851;
MIANALYZE procedure do imputation using non missing observation.,
a****a
发帖数: 3411
47
来自主题: Statistics版 - 请教一个macro的问题
新手问一个宏的问题
我想根据continuous variable的percentile value做一个categorical variable,比
方说有100个categories的categorical variable。
如果分组很多,输入不方便,修改一次变量名累也累死。
如何修改下面这个宏,能够实现划分任意多的category?
多谢 (包子不多2个)
%macro quint(dsn,var,quintvar);
proc univariate noprint data=&dsn;
var &var;
output out=quintile pctlpts=25,50,75,100 pctlpre=pct;
run;
data _null_;
set quintile;
call symput('q1',pct25) ;
call symput('q2',pct50) ;
call symput('q3',pct75) ;
call symput('q4',pct100) ;
run;
data &dsn;
set &dsn;
if &var =. ... 阅读全帖
o****o
发帖数: 8077
48
来自主题: Statistics版 - 求一个简单点的方法写一段SAS
data test;
do id='a', 'b', 'c';
do day=1 to 100;
sale=ranuni(9796876)*100;
output;
end;
end;
run;
data fmt;
retain fmtname 'cssale' type 'n' hlo 'M';
retain start 1;
do end=10 to 100 by 10;
label=cats(put(end, Z3.),'d');
output;
end;
run;
proc format cntlin=fmt cntlout=fmtchk;
run;
proc means data=test noprint nway;
by id;
class day /mlf exclusive;
format day cssale.;
var ... 阅读全帖
o****o
发帖数: 8077
49
proc means data=yourdata noprint;
by id;
var medication_:;
output out=newdata(where=(_STAT_='MAX') drop=_TYPE_ _FREQ_) ;
run;
baozi pls...
i******n
发帖数: 839
50
来自主题: Statistics版 - 如何判断一个dataset是不是空的?
This is much better one,
proc contents data=empty noprint out=out;
run;
proc print data=out;
title "proc content";
var memname nobs;
run;
1 2 下页 末页 (共2页)