d**********o 发帖数: 1321 | 1 再问一下:
proc contents data=dqa.ni_adjustment_factor; run;
ERROR: File DQA.NI_ADJUSTMENT_FACTOR.DATA does not exist.
保留版本work.ni_adjustment_factor_200901 (&per1=200901)是可以manipulate的。repeated run of "%varname;" will overwrite work.ni_adjustment_factor_200901.
而dqa libname中明明看见数据在,而且可以打开数据表,为什么用code就不能access呢?
而且dqa中存几个同样名字dqa.ni_adjustment_factor同样大小的表(repeated run of %varname;)sas并不识别?
dqa.ni_adjustment_factor是这么建的:
%macro varname;
data _null_;
set varname end=last;
call symput... 阅读全帖 |
|
g******d 发帖数: 231 | 2 我用了下面的code把 .csv 文件import到SAS里。file有很多columns, 而且都带有小数
位。
PROC IMPORT OUT=work.getit
FILE="C:\source.csv"
DBMS=csv REPLACE;
GETNAMES=YES;
DATAROW=2;
RUN;
import之后出现了一个状况:有一个column不能import成功。
在log file中其他的column的import过程显示:informat varname best32. -->
format varname best12. (input varname)。
但是这个column的显示是informat varname $1. --> format varname $1. (input
varname $ ). 但是明明source file中,该column就是numeric的。
请大虾指教。这是怎么回事,有办法修正吗?
十分感谢! |
|
l*******G 发帖数: 1191 | 3 OO 的另外一个大问题是 程序hierarchy 太多,引用变量时需要用 objectname.
varname ,很容易把人搞得晕头转向。
读程序的时候,人的眼睛首先扫过objectname 然后才看到varname,这个过程一点也不
自然。人们更习惯于先看到varname然后马上知道变量是干什么用的了。如同我们平时
更多用First name称呼别人。这个对于数学物理来说是disaster,没有人用object.
velocity 表示物体的速度,而是直接用v_m 简单明了。我建议以后变量和object引用
的时候反过来!比如说Varname<--objectname |
|
T*****e 发帖数: 361 | 4 In Perl, separating words with mixed caps in an identifier
like "RuntimeException" as "Runtime Exception" is fairly
easy. The regular expression for this can be:
$varName =~ s/([A-Z])/ \1/g;
or even better:
$varName =~ s/([^A-Z])([A-Z])/\1 \2/g;
$varName =~ s/([A-Z])([A-Z][a-z])/\1 \2/g;
Java's regular expression is pretty close to that of Perl
in term of searching for a pattern. However, can we do
similar replacement in Java without having to write a loop
to do searching and manua |
|
c*******o 发帖数: 8869 | 5 写一个R PROGRAM 用来分析不同的PROJECT, 每个PROJECT VARIABLE 名字不同, 想大
概写成这样:
VARNAME<- "STUDY1_VAR"
#############################
DATA$VARNAME<- @%^@%^#$%^@#$%^#$%^@
#############################
这样每次分析不同的DATA只要改最前面一行, 输入新的VARNAME就行了, 而不用在
CODE里改来改去。 但是我的思路不工作, 请问怎样是正确的做法呢?
谢了 |
|
c*******o 发帖数: 8869 | 6 多谢了, DATA[[VARNAME]] WORK了!但是建模的时候又不行了
attach(data)
test<- lme(data=data, data[[VARNAME]]~X*Y, random=-1|Z/U)
DATA[[VARNAME]] 在lme里不好使, 有什么建议吗? |
|
l*******G 发帖数: 1191 | 7 use ` ` or $()
such as
varname=$(sqlplus -silent id/password@oracel_instance <
echo $varname |
|
c******d 发帖数: 141 | 8 在matlab里,我可以做以下事情,
m=100;
n=10;
varname = ['myname_' num2str(n)];
eval([varname '=m;']);
在C里面我可以做类似的事情吗? |
|
a********a 发帖数: 3176 | 9 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, |
|
f********m 发帖数: 197 | 10 Is it possible that you define two arrays, one store variable name, one
store newlabel,say
...
array varname{3} $ ('a' 'b' 'c');
array label_of_var{3} $ ('aaa','bbb','ccc');
...
Then you define the macro as
%macro labels (var_to_label=, label_of_var=);
...
label &var_to_label = &label_of_var;
...
%mend;
do i=1 to 3;
%labels(var_to_label=varname{i}, label_of_var=newlabel{i});
end;
May worth a shot. But I'm not sure if it will work. :) |
|
a***r 发帖数: 420 | 11 抛砖引玉
#original matrix: A
#new matrix: X
#number of obs:n
#number of var:nvar
> A
var1 var2 var3 var4 var5
1 1 2 3 4 5
2 6 7 8 9 10
3 11 12 13 14 15
4 16 17 18 19 20
>n=4
>nvar=5
>value <-as.vector(t(A))
>varname <-rep(colnames(A),n)
>ID <-sort(rep((1:n),nvar))
>X <-data.frame(cbind(ID,varname,value))
ID var value
1 1 var1 1
2 1 var2 2
3 1 var3 3
4 1 var4 4
5 1 var5 5
6 2 var1 6
7 2 var2 7
8 2 var3 |
|
p***r 发帖数: 920 | 12 data<-data.frame(matrix(101:106,2,3))
> data
X1 X2 X3
1 101 103 105
2 102 104 106
> newdata<-
data.frame(id=rep(rownames(data),dim(data)[2]),varname=rep(colnames(data
),dim(data)[1]),value=c(t(as.matrix(data))))
> newdata
id varname value
1 1 X1 101
2 2 X2 103
3 1 X3 105
4 2 X1 102
5 1 X2 104
6 2 X3 106 |
|
g**********t 发帖数: 475 | 13 VARNAME<- "STUDY1_VAR"
DATA[[VARNAME]]<- @%^@%^#$%^@#$%^#$%^@
这样应该可以。 |
|
h*********n 发帖数: 278 | 14 要写一个类似如下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
也找不到解决方法,求牛人指教! |
|
g******2 发帖数: 234 | 15 data$varname -> data[, varname] |
|
n********6 发帖数: 1511 | 16 Thank you all. Problem solved. I used it in ASP. Already in string. Just
misplaced the single quote(') for the object name (varname).
The above question is oversimplified and misrepresented. |
|
S*A 发帖数: 7142 | 17 不会用 csh.
bash 里面大概是
varname=`sqlplus -silent id/password@oracel_instance <
printf("%s",$1;}'
"%s",$1;}' `
printf( |
|
s*****e 发帖数: 11 | 18 You can try to use "split" function.
e.g. try
split VARNAME, p("a", "b", "c", "d",..."x", "y", "z") |
|
z**********i 发帖数: 12276 | 19 4 variables 633 observations.
form gateval varname gatevarname
a 1 blood race
..
..
..
Thanks. |
|
s**********e 发帖数: 63 | 20 Use "Input" statement:
For example:
input("varname", length);
run; |
|
o****o 发帖数: 8077 | 21 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||'"')||' |
|
d*******1 发帖数: 854 | 22 例子
ID VAR1 VAR2 VAR3
1 1 2 3
2 4 5 6
转化成:
ID VARNAME VALUE
1 VAR1 1
1 VAR2 2
1 VAR3 3
2 VAR1 4
2 VAR2 5
2 VAR3 6
column |
|
l**********s 发帖数: 255 | 23 上周牛人们帮我解答了困惑,以下是我的数据和牛人们的code 。 假使我把数据稍稍修
改下, 变成data two, 改动的地方就是把ID=5的那一行,所有的数据都变成0。这样前
半部分code可以照样运行,后半部分code合并的时候,最后生成的数据里面varname的
值是混乱的,改了几次都不行。只知道是前半部分code运行后自动生成的某些文件里面
没有observation造成的,最后问下,其实后半部分code都每怎么看懂,有什么通俗易
懂的入门材料推荐下?多谢多谢。
________________________________
不好意思,新数据在6楼。 |
|
|
D******n 发帖数: 2836 | 25 create a .vim directory under you home directory(there is a dot before
vim)
and then create a syntax directory under it
and then create a sas.vim file under the syntax directory
==============sas.vim======================
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
syn case ignore
syn region sasString start=+"+ skip=+\\|\"+ end=+"+
syn region sasString start=+'+ skip=+\\|\"+ end=+'+
" Want region from 'cards;' to ';' to be captured (Bob Heckel)
sy... 阅读全帖 |
|
z****g 发帖数: 1978 | 26 as.formula( paste( VARNAME, '~X*Y', collapse = '') ); |
|
d**********o 发帖数: 1321 | 27 和你查的一样,
proc gchart data=xxx;
vbar varname / midpoints='value1' 'value2';
run; quit;
不work没道理啊? |
|
o****o 发帖数: 8077 | 28 data _xxx;
input var1 var2 var3 var4;
cards;
2 4 6 7
4 9 7 6
5 2 1 1
7 3 7 3
;
run;
proc transpose data=_xxx out=_xxx2;
run;
proc means data=_xxx2 noprint;
var col1-col4;
output out=_xxx3(keep=v1-v4)
maxid(col1(_name_)
col2(_name_)
col3(_name_)
col4(_NAME_))= v1-v4/autoname;
run;
proc transpose data=_xxx3 out=_xxx3t;
var v1-v4;
run;
d... 阅读全帖 |
|
c**d 发帖数: 104 | 29 maybe you can do this way (I did not write the whole codes):
/* 1: work on numeric */
/* output data include 3 columns:id, label, max value */
proc means data = test;
class id;
var _numeric_;
output out= max = _max;
run;
/* transpose by id and use label as variable name*/
proc transpose;
run;
/* 2: work on char variables */
/* you can also get id, varname, unique value and freq */
proc freq data = test;
table id*_char_;
ods output freqtable;
run;
/* do a data step to remove the row id*id in the... 阅读全帖 |
|