由买买提看人间百态

topics

全部话题 - 话题: var1
首页 上页 1 2 3 4 5 6 7 (共7页)
l*********s
发帖数: 5409
1
来自主题: Statistics版 - Weird SAS macro bugs, 包子重谢!
I am having some very weird bug while trying to write a macro that can
expend the short hand notion like var1--var11 used in SAS.
The "shorthand" macro works fine on its own, but fails to work when called
by the "formula" macro. The error message seems to say that "the set
statement in the data step is not valid or not in proper order", what's
going on?
Many thanks!
////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////... 阅读全帖
x*******u
发帖数: 500
2
来自主题: Statistics版 - help! 读CSV文件读得要崩溃了
我试了, 还是老样子。 能不能把你的code贴上来看看, 谢谢。
还有, 如果我ignore数据的形式, 计算 a=(hour*60+min)*60+sec;
error message is:
NOTE: Invalid numeric data, hour='.1.2.' , at line 663 column 8.
var1= 1 0 / 3 0 / 2 0 0 9 VAR2= 1 2 : 2 1 : 2 9 P M VAR3= 0 . 0 0 VAR4=
6 8 . 0 month= 1 0 day= 3 0 year= 2 0 0 9 AMPM= P M hour= 1 2 min= 2 1
sec= 2 9 var6= 1 2 : 2 1 : 2 9 a=. _ERROR_=1 _N_=2
d******9
发帖数: 404
3
来自主题: Statistics版 - 请教关于SAS表格输出的问题
如果是freq的,为什么var1 跟var2的total不一样。???
Co-ask. It the output really frequency??????????
a*****3
发帖数: 601
4
来自主题: Statistics版 - format problem, urgent
什么是 x window ??
反正我觉得sas造了个黑盒子, 文档也写得不明不白, 比如最简单的format/informat,
这连个东西什么区别,里面的实现机制, 文档里可是语焉不详, 我看了好几遍都没
看懂. 问个最最简单的,如何定义 numeric/character informat/format = ? 我出20
伪币 看谁能把定义从文档里找出来.
再比如说排序这个事, 里面的mechanics也不清楚, 比如说,排玩序了,是在dataset
里面做了记号,还是在pdv里面做了什么手脚? First. Last. 然后是根据什么生成的
?尤其象by var1 var2 var3, 然后引用First.Var2 这种情况 文档里可是一点没说
呀.
还有通过ods结合各种procs生成的dataset, 里面是什么变量,什么命名规则,目前还
没研究过文档..估计也是写得一塌糊涂.
总之 这个黑盒子也许不错, 就是太黑了。
L****n
发帖数: 3545
5
来自主题: Statistics版 - 我也来请教一个SAS问题
一个SQL select count(distinct var1),count(distinct id) into :v1, v2
然后一个DATA STEP SET 原数据加上两列常数值。
至于GROUP BY,没明白你要干啥。
h******3
发帖数: 190
6
来自主题: Statistics版 - 如何在R里refer上一个row的值
I see. Sorry, I did not express this clearly.I want to refer to the last
value in a column in a data frame. For instance, var1[(var2 in the last row)
==1, ]
我也试了一下这个.Last.value.确实可以显示。虽然不是我想要做的。多谢!:P

command. what do you mean by 上一个row的值 啊?
t*******t
发帖数: 633
7
来自主题: Statistics版 - 如何在R里refer上一个row的值
想到这个笨方法,抛砖引玉吧。
for (i in 2:dim(data)[1]){
data_out[i]<-data[data$var2[i-1]==1,]$var1[i]}

row)
d******9
发帖数: 404
8
来自主题: Statistics版 - SAS if 问题一个
it =
if Var1=1 and Var=1 (then keep the observation) ;
k*****u
发帖数: 1688
9
原作者为 爱萌@人大经济论坛,本文是我转载过来的。
文本挖掘是新时期人们对数据的更加深入的需求的,文本挖掘的原材料是各种文本格式
的文本,文字,图片,通过这些来分析相似,关键性,内部蕴涵的逻辑结构等等.
文本数据多是半结构化的数据,(结构化数据是有一定规律的数据,半结构化,是这些文本
有标题,作者,出版日期,类别等结构的东西,同时也有非结构的成分:内容)
文本挖掘有很多方法,基于关键字的方法,标记方法,信息提取方法.
web挖掘是对网页的挖掘,这是因为随着www的发展,
越来越多的信息在网络中,这些数据不仅对商业,对经济,
而且对政治,文化有很深远的影响. web挖掘可以分为web内容挖掘,web结构挖掘,web使
用挖掘,
可以根据html语言对web进行文本挖掘从而达到web挖掘,
但是很多网页并不遵守W3C html规范.
如何通过SAS进行编程对文本,web进行挖掘
为什么我一直在说SAS的文本挖掘和web挖掘,因为这些程序我还不知道如何编写,
其他程序我都知道了,也编写过了.
这是与算法相关的了!
文本挖掘是数据挖掘的一种,有时也看成是质性研究的一种方法。大致的... 阅读全帖
v********9
发帖数: 35
10
来自主题: Statistics版 - 如何把一个变量分割成两个
merge test(rename=(v1=Var1) firstobs=1 obs=3)
test(rename=(v1=Var2) firstobs=4 obs=6) ;
N******n
发帖数: 3003
11
来自主题: Statistics版 - Residual and Partial Correlation

show
你也可以simulate outcome=beta1*var1+beta2*var2, beta1 and beta2 can be
assumed as their corresponding partial correlation
H**********1
发帖数: 3056
12
来自主题: Statistics版 - SAS question,thanks!
I want to select all the 40 variables from data set
but, I want to delete all the missing value for any of the variable.
how to do this?
I don't want to use 4O TIMES "if VAR1 IS NOT MISSING OR...."
THANKS!
c******n
发帖数: 380
13
if indexc(catx('',of var1-var4),'xyz')>0 then target=1;else target=0
s******r
发帖数: 1524
14
You assume var1-var4 is one-letter variable. It may not be true.
t********m
发帖数: 939
15
这个works,非常感谢!我自己写的时候,没用missing function,而是用了下面的if.
..else,所以逻辑怎么都搞不对,要么是不加output,只输出最后的var4满足条件的
records;要么就是加output,最后每个var满足的records都被输出了,其中难免有重
复的。Thanks again!
data test;
set test;
array var(4) var1-var4;
do i=1 to 4;
if drugid(i) in ('x','y','z') then steroid=1;
else steroid=0;
*output;
end;
run;
s******r
发帖数: 1524
16
Your code could work after a little change.
data test;
set test;
array drugid(4) var1-var4;
steroid=0;
do i=1 to 4;
if drugid(i) in ('x','y','z') then steroid=1;
end;
if steroid=0 then delete;
drop i;
run;

if.
m*****a
发帖数: 658
17
I mean why f indexc(of var1-var4,'xyz)>0 then target=1;else target=0 ,
doesnt work ?
p***e
发帖数: 118
18
来自主题: Statistics版 - 简单的SAS问题
Var1 var2
1 A
2 B
3 N
4 Q
5 K
怎么样简单的创建一个SAS Macro variable
比如说: MacroVariable,value是 A B N Q K
比如 %put MacroVariable, 显示 A B N Q K,
相当于 %let MacroVariable = A B N Q K
谢谢谢谢
p***e
发帖数: 118
19
来自主题: Statistics版 - 简单的SAS问题
Var1 var2
1 A
2 B
3 N
4 Q
5 K
6 K
7 K
如果是 这种情况,怎么不重复5,6,7?
谢谢谢谢
k*****u
发帖数: 1688
20
%let myvar=var1...var50;
proc tabulate data=yourdata;
class &myvar.;
table &myvar., n;
run;
k*******a
发帖数: 772
21
可以用 SAS 的dictionary来找出data有什么variable
data test;
input var1 $ var2 $;
datalines;
3.4 5
4.55 5.3
4 3.444
;
run;
proc sql noprint;
select strip(name)||"_n=input("||strip(name)||",best12.)" into :convert
separated by ";"
from sashelp.vcolumn
where libname="WORK" and upcase(memname)="TEST";
quit;
data test1;
set test;
&convert;
run;
d******9
发帖数: 404
22
来自主题: Statistics版 - SAS MACRO question (包子求教重金酬谢)
If you do NOT have so many variables, you can rename the variables manually,
the below MACRO will work.
Please send me your BAOZI, thank you.
-------------------------------------------------------------
libname A 'your physical path';
****Use SAS MACRO to read in external CSV files from storage library.****;
filename Raw 'your physical path';
data AAA (drop=RC);
length Memname In_Name Out_Name $30;
Did=dopen("Raw");
if did> 0 then do;
Num=dnum(did);
do J=1 to Num;
Memname=dread(did, J);
In_Na... 阅读全帖
c*****a
发帖数: 16
23
来自主题: Statistics版 - SAS MACRO question (包子求教重金酬谢)
I will single out those different files first.
Also, since I have 49 variables, could you pls help me with how to get them?
If it is not easy, that is OK - I will do it mannually. Thanks a lot.
proc import datafile=Mem&I out= A.&&OUT&I(rename=(var1=Date &#
160; var2=Tier &#
160;var3= Ccy var4= Doc var5=Sd1y &#
160; var6=Sd2y))
DBMS=CSV REPLACE;
s*****a
发帖数: 2735
24
来自主题: Statistics版 - SAS Graphic question - help please
axis1 label=none order=(1 to 13)/*??x axis 的范围*/
value=(j=c "12AM" " " "12PM" " ""12AM" " ""12PM" " ""12AM"
" ""12PM" " ""12AM");
/* ..... */
proc gplot;
plot var1*var2 / haxis = axis1;
run;
/* ???可行 *//
j*****g
发帖数: 36
25
来自主题: Statistics版 - 重新安排变量的问题
proc transpose data = dataset0 out=dataset1 name=variable;
by farm year land;
var var1-var3;
drop _label_;
run;
proc sort data = dataset1;
by farm land variable year;
run;
data dataset2(drop = variable year); set dataset1;
newId = catx("_", variable, year);
run;
proc transpose data = dataset1 out =dataset2;
by farm land;
id = newId;
var = col1;
drop _name_ _label_;
run;
p********1
发帖数: 1011
26
Logistic regression Number of obs = 28997
LR chi2(11) = 59.25
Prob > chi2 = 0.0000
Log likelihood = -1125.0894 Pseudo R2 = 0.0257
------------------------------------------------------------
y | Odds Ratio P>|z| [95% Conf. Interval]
-------------+----------------------------------------------
var1 |
1 | ... 阅读全帖
s******r
发帖数: 1524
27
来自主题: Statistics版 - 问一个SAS 的问题
I would suggest you to break the dataset into two sets. One set contains
var1 and another one contains var2.
set I;
var_id value
1 looks
l like
2 disney;
proc sql;
select I.var_id, count(*) as cnt from
I inner join II
on I.var_id=II.var_id and I.value=II.value
group by I.var_id;quit;run;
set
A****1
发帖数: 33
28
来自主题: Statistics版 - 怎么解决这个sas macro的问题?
change the into operator to:
into :mentor_2 separated by '", "'
Be careful with IN operator: if var1 in ("A","B","C");

),
unbalanced
c**d
发帖数: 104
29
来自主题: Statistics版 - 包子问题请教( sas)
楼主给了包子,要负责到底。
1. 试试能不能下载:http://support.sas.com/rnd/app/da/glmselect.html
2. 如果不能,write a macro or use R
3: update SAS to 9.2 or later
/* step 1: generate all Combinations */
/* use the macro from SAS */
/* http://support.sas.com/techsup/technote/ts498.html */
%combo(2,a,b,c)
proc sort data = combo;
by v1 v2;
run;
/* step 2: create interaction Equations*/
data combo;
set combo;
length eq $100;
eq = cat("it_", strip(put(_n_,8.)),
'=', strip(v1), '*', strip(v2));
... 阅读全帖
y**i
发帖数: 1050
30
来自主题: Statistics版 - help!! help!! SAS help!! Urgent!!
thank you
I changed my data, actually has 3 VARs.
I have VAR3, how can I count level of VAR3 condition on VAR2 and VAR1
thanks
y**i
发帖数: 1050
31
来自主题: Statistics版 - help!! help!! SAS help!! Urgent!!
thank you
I just changed my data variables
I have 3 VAR, I want to get the number of level of VAR3 condition on
VAR2 and condition on VAR1.
how can I do it? and I want to put this number into do loop;
like: " do i=1 to number "
thanks
S*******1
发帖数: 251
32
来自主题: Statistics版 - help!! help!! SAS help!! Urgent!!
sorry, I think by remove the duplicates, you may wrongly removed some level
of var3 FROM the same level of var1 and var2.
S*******1
发帖数: 251
33
来自主题: Statistics版 - help!! help!! SAS help!! Urgent!!
I htink you make use the sort by var1 var2
then use the rank function
then get the rank number by if last.rank

level
A***8
发帖数: 189
34
来自主题: Statistics版 - 怎么用SAS transpose这两dataset呀?
data structure列在下面啦,哪位达人能帮着看一下怎么从1变到2,从2变到1。
包子酬谢!
dataset1:
index var1 var1_description var2 var2_description
1 cd02 cd02_text cd05 cd05_text
2 cd05 cd05_text cd03 cd03_text
3 cd03 cd03_text cd04 cd04_text
4 cd10 cd10_text cd08 cd08_text
dataset2:
index var description
1 cd02 cd02_text
1 cd05 cd05_text
2 cd05 cd05_text
2 cd03 cd03_text
3 cd03 cd03_text
3 cd04 cd04_text
4 cd10 cd10... 阅读全帖
t*****w
发帖数: 254
35
来自主题: Statistics版 - 怎么用SAS transpose这两dataset呀?
data set2 (keep=x1 x2);
set set1 ;
array y1{2} $ var1 var1_description;
array y2{2} $ var2 var2_description;
x1=y1{1};
x2=y1{2};
output;
x1=y2{1};
x2=y2{2};
output;
run;
d********h
发帖数: 2048
36
来自主题: Statistics版 - 求大牛解答 SQL 问题
不用那么麻烦,
proc sort;by id descending var3 descending var2 descending var1;
data test;
set test;
if first.id then output;
run;
s******8
发帖数: 102
37
用数据步,从头到尾走一边,把最大值保持到最后输出。
data maximuvalue;
set yourdata end=last;
array var(4) var1-var4;
array max(4);
retain max1 max2 max3 max4 0;
do i=1 to 4;
if var(i) gt max(i) then max(i)=var(i);
end;
if last then output;
keep max1-max4;
run;
x*******i
发帖数: 1237
38
来自主题: Statistics版 - 请教一个SAS ARRAY的问题
DATA time_variant1 time_variant2;
SET var_res;
ARRAY var {2} var1 var2;
ARRAY dataset {2} time_variant1 time_variant2;
DO i=1 to 2;
IF var_nm=var{i} THEN OUTPUT dataset{i};
END;
RUN;
为什么SYNTAX ERROR UNDER output dataset{i}?
THX!!
s*******e
发帖数: 1385
39
来自主题: Statistics版 - Please help with a SAS macro
我没有SAS,你可以试试这个程序。
data temp;
set yourdata;
retain total 0;
var2=(total+var1)/_N_;
run;

field
m***c
发帖数: 118
40
来自主题: Statistics版 - Please help with a SAS macro
proc sort data=one; by month var; run;
data two; set one; by month var;
var2+var1;
var2/_n_;
run;
飞越
h*******n
发帖数: 458
41
楼上问的是把这一句
and 1<=intck('month', b.date, a.date)<=60;
变成WHERE。我觉得是可以的,效率哪个更高就不清楚了。直觉上是WHERE效率高。
另外,把一个record复制多遍可以这样做:
data new;
set old;
do i=1 to Ntimes;
retain var1 var2 … varM;
output;
end;
run;
不过复制后的DATE还是原来的值,没变。你可以产生一个新的DATASET,含你MERGE要用
的ID var,每个弄若干行(60个月的天数),再加一个DATE,在和上面CODE类似的循环
里用INTNX产生要的日期。然后MERGE。
h*********n
发帖数: 278
42
来自主题: Statistics版 - 郁闷死了,请教一个R的问题
要写一个类似如下function, 需要读取一个现有数据中的variable name作为parameter
, 然后create a new variable that's the same as this variable but in a
different name, or renaming this variable would work too.
func <- function(varname) {
data$newvarname <- data$varname
#之后有很多步骤都是用这个newvarname
}
func("var1")
无奈怎么也不work,就是没法在data里create这个新变量,折腾一天了,好郁闷啊,
SAS里只需要用macro variable就行了,搜索pass variable name to a function in R
也找不到解决方法,求牛人指教!
a**w
发帖数: 60
43
如何避免?
例如, 在下例中, 抽取的总样本数1400中, 可以有大概1/3的样本是1次,或2次,3次,...
, 重复的.
proc surveyselect data=s /* 10000 个数据 */
method=sys
n=200
reps=7
seed=37652
out=s1
;
control var1 var2 var3;
run;
如果设置 seed=0, 那么样本重复数会小一些, 但是重复率仍然很大.
请大家帮忙看看该怎么处理. 谢谢!
a**w
发帖数: 60
44
No. What I need to do is to make sure there are no any replicates in the
output
data set when reps is greater or equal to 2. Example is like this:
proc surveyselect data=s method=sys
n=1000
reps=7
seed=354545
out=s1;
control var1 var2 var3;
run;
a**w
发帖数: 60
45
I tried to use a data step, but can't get the requested result.
%macro sum;
data a1;
set s;
by var1 var2 var3;
%do i=1 %to 100;
if first.var3 then %do;
sum_QH&i.=0;
sum_QH&i.+QH&i.;
sum_Q=0;
SUM_Q+Q;
if last.var3;
%end;
%end;
run;
data a;
set a1;
%do %i=1 %to 100;
F=sum_QH&i./sum_Q;
%end;
run;
%mend sum;
%sum
y**3
发帖数: 267
46
来自主题: Statistics版 - sas coding help needed
Thanks for the help!
But this way tem was set only var2/var1 at _n_=1. that is, tem is same for
all the rest of rows. But I need to re compute tem using the new var2 for
every rows. A do loop work?

发帖数: 1
47
来自主题: Statistics版 - sas coding help needed
According to your description, "tem=var2/var1" should have the same value
for all lines, right?
w*****1
发帖数: 473
48
来自主题: Statistics版 - 请教proc transpose 问题
我想用proc transpose 把long data 转化为wide data,但是转化以后的column name
变成了var1, var2 var3 var4....,而不是原来的probe_id。我用了profix=probe_id,
结果column name 变成了probe_id1, probe_id2...,而不是原来的PROBE_ID,我希望转
化以后的column name 是ILMN_1762337,ILMN_2055271......
下面是 long data的部分数据,从第三个变量开始是sample name,下面的数据是gene
expression level,一共有几百个sample, 几十万个probe.
PROBE_ID SYMBOL 5117-H471Fwk12-B3.AVG_Signal
ILMN_1762337 7A5 18.56415
ILMN_2055271 A1BG 33.11682
ILMN_1736007 A1BG -3.966002
ILMN_2383229 A1CF ... 阅读全帖
w*****1
发帖数: 473
49
来自主题: DataSciences版 - 请教proc transpose 问题 (转载)
【 以下文字转载自 Statistics 讨论区 】
发信人: wz99331 (dotti), 信区: Statistics
标 题: 请教proc transpose 问题
发信站: BBS 未名空间站 (Wed Oct 25 15:16:10 2017, 美东)
我想用proc transpose 把long data 转化为wide data,但是转化以后的column name
变成了var1, var2 var3 var4....,而不是原来的probe_id。我用了profix=probe_id,
结果column name 变成了probe_id1, probe_id2...,而不是原来的PROBE_ID,我希望转
化以后的column name 是ILMN_1762337,ILMN_2055271......
下面是 long data的部分数据,从第三个变量开始是sample name,下面的数据是gene
expression level,一共有几百个sample, 几十万个probe.
PROBE_ID SYMBOL 5117-H471Fwk12-... 阅读全帖
a********l
发帖数: 39524
首页 上页 1 2 3 4 5 6 7 (共7页)