由买买提看人间百态

topics

全部话题 - 话题: sysfunc
1 (共1页)
l*********l
发帖数: 2371
1
来自主题: Statistics版 - need sas debug help!! Please...
%macro run_code;
*%let start=%sysfunc(inputn('01feb09'd,anydtdte9.));
*%let end=%sysfunc(inputn('01jun13',anydtdte9.));
%let start=%sysfunc(inputn('01dec11'd,anydtdte9.)); %put &start;
%let end=%sysfunc(inputn('01feb12'd,anydtdte9.));
/*determines the number of months between the two dates*/
%let dif=%sysfunc(intck(month,&start,&end));
%do i=0 %to &dif;
%let date =%sysfunc(putn(%sysfunc(intnx(month,&start,&i,b)),yymmn6.)
);
%let date2=%sysfunc(putn(%sysfunc(in... 阅读全帖
z**********i
发帖数: 88
2
%LET B=428;
%LET B_F_A=%EVAL(%SYSFUNC(ROUND(&B.*.75*.95,1)));
%LET B_F_O=%EVAL(%SYSFUNC(ROUND(&B.*.75*.05,1)));
%LET B_O_A=%EVAL(%SYSFUNC(ROUND(&B.*.25*.95,1)));
%LET B_O_O=%EVAL(%SYSFUNC(ROUND(&B.*.25*.05,1)));
%LET C=22;
%LET C_F_A=%EVAL(%SYSFUNC(ROUND(&C.*.75*.95,1)));
%LET C_F_O=%EVAL(%SYSFUNC(ROUND(&C.*.75*.05,1)));
%LET C_O_A=%EVAL(%SYSFUNC(ROUND(&C.*.25*.95,1)));
%LET C_O_O=%EVAL(%SYSFUNC(ROUND(&C.*.25*.05,1)));
%PUT
&B_F_A &B_F_O &B_O_A &B_O_O &C_F_A &C_F_O &C_O_A &C_O_O;
DATA SIZE;
ARRA... 阅读全帖
l***a
发帖数: 12410
3
来自主题: Statistics版 - why this error in %if statement
38 %else %if %sysfunc(weekday(%sysfunc(today()))) in (4,6) %then %do;
39 data _null_; call symput('n',4); run;
40 %end;
ERROR: Required operator not found in expression: %sysfunc(weekday(%sysfunc(
today()))) in (4,6)
ERROR: The macro DATES will stop executing.
s******y
发帖数: 352
4
%let somedt1=21APR2011;
%let somedt2=01Jun2011;
%put current session date: &sysdate;
%put &somedt1. > &sysdate.? %eval(%sysfunc(inputN(&somedt1,date9))>%sysfunc
(inputN(&sysdate.,date9)));
%put &somedt2. > &sysdate.? %eval(%sysfunc(inputN(&somedt2,date9))>%sysfunc
(inputN(&sysdate.,date9)));
BAOZI please!!
o******l
发帖数: 3125
5
来自主题: Statistics版 - sas 代码问题
%let sambeg = %sysfunc(mdy(6, 30, 1985)) ;
%let samend = %sysfunc(mdy(12, 31, 2011));
%let nummon = %sysfunc(intck('month', &sambeg, &samend));
%macro overall;
%do i = 1 %to &nummon;
%let t = %sysfunc(intnx('month', &sambeg, &i, 'end'));
%months(&t, 6, 6);
%end;
%mend overall;
%overall;
在macro里面,要用到系统函数的时候,应该怎么用?
怎样修改上面的代码呢?
谢谢!
l*********t
发帖数: 18
6
来自主题: Statistics版 - 问一个SAS macro的问题
我写了一个很短的macro, 用来提取sas dataset的attribute.
%macro getattrn(indata=, attrn=);
%if %sysfunc(exist(&indata)) %then %do;
%* open data set;
%let did=%sysfunc(open(&indata));
%* Get attribute;
%let attvalue=%sysfunc(attrn(&did, &attrn));
%* Close data set;
%sysfunc(close(&did));
%end;
%else %let attvalue=-999;
&attvalue
%mend getattrn;
然后call的时候就把值赋给一个marco variable, 比如
%let MV=%getattrn(indata=mydata, attrn=nobs)
按道理这个macro应该返回mydata里面的observation个数. 但是我查MV的值竟然是:
0; 396... 阅读全帖
d********i
发帖数: 193
7
来自主题: Statistics版 - need sas debug help!! Please...
Change the following lines:
*%let start=%sysfunc(inputn('01feb09'd,anydtdte9.));
*%let end=%sysfunc(inputn('01jun13',anydtdte9.));
to:
%*let start=%sysfunc(inputn('01feb09'd,anydtdte9.));
%*let end=%sysfunc(inputn('01jun13',anydtdte9.));
o******l
发帖数: 3125
8
来自主题: Statistics版 - sas 代码问题
%let sambeg = %sysfunc(mdy(6, 30, 1985)) ;
%let samend = %sysfunc(mdy(12, 31, 2011));
%let nummon = %sysfunc(intck('month', &sambeg, &samend));
最后一行应该怎么改? 试过 %eval还是不行。
谢谢!
p********a
发帖数: 5352
9
来自主题: Statistics版 - ODS target.ExcelXP 生成的EXCEL文件问题
I used the following codes. Could you help me to take a look and see what is
wrong? Thanks
%let datestamp=%sysfunc(today(),yymmddn8.);
%let datestamp1=%sysfunc(datetime(),datetime20.);
%let datestamp2=%substr(%sysfunc(tranwrd(&datestamp1,:,_)),1,15);
%put &datestamp1 &datestamp2;
ODS listing close;
ODS tagsets.ExcelXP path = "/sassvr1/test_report" file="sassrv1_at_%bquote(
&work1pct.)._&datestamp2._CST.xls"
style=EGDefault options( autofilter='all' embedded_titles='yes' autofit
_height= 'y... 阅读全帖
s******8
发帖数: 102
10
来自主题: Statistics版 - 请问关于交易量的一个SAS编程问题
我也试一下:
你的问题是数据太大,而又必须排序.所以在排序方法上着手. 若你知道日期跨度,第一
步安天拆分数据,然后对每天排序并检查,最后把结果合并起来.
假如最早date as macro variable Day1, last date as macro variable day2;
%let date1=mdy(1,1,1990);
%let date2=mdy(12,31,2012);
%macro trybest(day1=&date1,day2=&date2);
data %do i=&day1 %to &day2;dt_&i %end;;
set yourdate;
select(date);
%do i=&day1 %to &day2;
when(i) output dt_&i;
%end;
otherwise put "ERROR: other date found " date;
end;
drop date;
run;
%do i=&day1 %to &day2;
%let dsid=%sysfunc(open(dt_&I,i));
%let nobs=%sysf... 阅读全帖
g*******t
发帖数: 124
11
来自主题: Statistics版 - why this error in %if statement
%sysfunc出来的是不是char,这样的话,in就不对了。。

sysfunc(
e****8
发帖数: 200
12
来自主题: Statistics版 - SAS adv NEW Q23
我和你一样,开始觉得是B;但后来想想如果B对,A也就对,因为只是格式不同;所以两个都
不对;
online tutorial上有个类似的"Today is: %sysfunc(today(),", 所以考点应该就是是
%sysfunc()的用法,而不是system macro;不过不确定的是worddate.,后来final85告诉
我他确定D,所以就D啦 :P
(不好意思,我真的对于sas也是半瓶水啊~~, 你要基础好,最好自己运行程序试一试)
h******e
发帖数: 1791
13
来自主题: Statistics版 - help: sas error message
thanks, another question: what is the role of "< >" in the following code:
....................
%let a = < %str(%sysfunc(date(),date9.) : %sysfunc(time(),time5.)) >;
....................
l*********s
发帖数: 5409
14
来自主题: Statistics版 - SAS question
The code shall be correct. The writer is an expert of SAS,imho.
Furthermore, I am also confused by this statement:
%sysfunc(translate(%sysfunc(translate(&var,m,-)),P,.),
the syntax does not match the description in SAS help?
s******y
发帖数: 352
15
what about this?
%sysfunc(inputN(&somedt2,date9))>%sysfunc(inputN(&sysdate.,date9))
l***a
发帖数: 12410
16
来自主题: Statistics版 - SAS: how to build a timer
add this to both beginning and end of the code
%put %sysfunc(putn(%sysfunc(datetime()),datetime20.2));
k*******a
发帖数: 772
17
来自主题: Statistics版 - 问一个SAS macro的问题
我觉得是 %sysfunc(close(&did)); 这一句引起的
因为他返回0 ,如果改成 %let close=%sysfunc(close(&did)); 应该就好了
s*********h
发帖数: 6288
18
来自主题: Statistics版 - Help: SAS code
/*==============*/
%macro trans(date=);
%let mth = %sysfunc(month(&date)));
%let yr = %sysfunc(year(&date)));
%put &mth &yr;
%if &mth eq 1 %then %do;
%let preyr = %eval(&yr - 1);
%let premth = 12;
%end;
%else %do;
%let preyr = %eval(&yr);
%let premth = %eval(&mth - 1);
%end;
%end macro;
/*===========*/
%trans(date='01sep2013'd)
/*===Log====*/
24 %trans(date='01sep2013'd)
MLOGIC(TRANS): Beginning execution.
MLOGIC(TRANS): Parameter DATE has value '01sep2013'd
MLOGIC(... 阅读全帖
t*****w
发帖数: 254
19
来自主题: Statistics版 - Help: SAS code
%macro trans(date=);
%let mth = %sysfunc(month(&date),8.);
%let yr = %sysfunc(year(&date),8.);
%put &mth &yr;
%if &mth eq 1 %then %do;
%let preyr = %eval(&yr - 1);
%let premth = 12;
%end;
%else %do;
%let preyr = %eval(&yr);

%let premth = %eval(&mth - 1);
%end;
%mend macro;
/*===========*/
%trans(date='01sep2013'd);
d*********d
发帖数: 239
20
编了个MACRO程序想把 一个字符串 q1 q2 q5-q8 变成 q1#q2#q5-q8
原始程序如下
OPTIONS MPRINT;
OPTIONS SYMBOLGEN;
%MACRO convert(pound);
%DO i = 1 %TO %SYSFUNC(COUNTW(£,%STR( )));
%IF &i = 1 %THEN %LET list = %QSYSFUNC(SCAN(£,&i,%STR( )));
%ELSE %LET list = &list%STR(#)%QSYSFUNC(SCAN(£,&i,%STR( )));
%END;
%MEND convert;
%PUT %convert(q1 q2 q5-q8);
不给最终结果。mprint显示到q1#q2生成了,但不生成最后结果。程序也没出错。
当我把%DO循环改成
%DO i = 1 %TO %EVAL(%SYSFUNC(COUNTW(£,%STR( )))+1);
维持其他不变,就可以得到最终结果。
虽然得到了最终结果,但不明白为什么循环部分要加1.COUNTW结果... 阅读全帖
p********a
发帖数: 5352
21
来自主题: Statistics版 - batch?
/***insert r-submit here*******/
%macro a;
%do yy=3 %to 6;
%do mm=1 %to 12;
%let yymm=%sysfunc(mdy(&mm,01,&yy),yymmn4.);
%put &yymm;
%yourmacrob();
%end;
%end;
%mend;
%a;
f********l
发帖数: 26
22
来自主题: Statistics版 - batch?
Thanks again.
BUT why I submit the following script, no error and also no results??
RSUBMIT;
%MACRO MYMACRO;
%CONNECT(TTDATA);
PROC SQL;
%INCLUDE CONNECT;
DROP TABLE PP_&YYMM;
CREATE TABLE PP_&YYMM AS
SELECT *
FROM CONNECTION TO TTDATA
( SELECT H
FROM GL_&YYMM
);
QUIT;
%MEND MYMACRO;
%MACRO A;
%DO YY=3 %TO 6;
%DO MM=1 %TO 12;
%LET YYMM=%SYSFUNC(MDY(&MM,01,&YY),YYMMN4.);
%PUT &YYMM;
%MYMACRO;
%END;
%END;
%MEND;
ENDRSUBMIT;

couple
p********a
发帖数: 5352
23
来自主题: Statistics版 - [合集] 请教一个sas问题
☆─────────────────────────────────────☆
xiaotudou (我爱吃土豆) 于 (Thu Feb 28 21:24:24 2008) 提到:
如果先产生了一个dataset, 这个dataset有时是空的, 有时有observations. 我需
要写个if statement, 即, 如果这个dataset是空的, 做什么什么, 如果有obs, 做
什么什么. 请问这个if statement该怎么写.
我现在用比较罗嗦的方法, 用sql数这个dataset obs的个数,成为一个macro varia
ble. 然后if 这个macro variable=0 then do; else do; 请问有没有更好更简洁的
. 谢谢
☆─────────────────────────────────────☆
papertigra (长工胖头猪) 于 (Thu Feb 28 23:37:51 2008) 提到:
Try:
%if %SYSFUNC(ATTRN(data-set_id,‘nobs'))>0 %then
☆────
d*******1
发帖数: 293
24
来自主题: Statistics版 - 请教 SAS macro function 的问题
我用下面的code, 但是出错,好像是参数类型传递错误
%macro derv(lambda);
%global dl;
%let temp1 = %sysfunc(exp(-&lambda));
%let dl = %sysevalf(10/&lambda + 25*&temp1/(1-&temp1) - 27.21);
%mend derv;
Data;
Lam_1 = 0.1;
%derv(Lam_1);
出错 (我把它改成 %derv(0.1) 就没有问题, 但是dl的值有问题,不知道用的时候,可不可以这样用)
ERROR: A character operand was found in the %EVAL function or %IF condition
where a numeric operand is required.
我这儿需要把Lam_1转换成numeric type吗? 用什么函数可以转化?
另外, 对于Macro parameters, 好像只有输入参数,可以把参数设置成输出参数吗,要不
然,觉得很不方便,要不断使用global v
A*********u
发帖数: 8976
25
来自主题: Statistics版 - 请教 SAS macro function 的问题
如果只是计算,为啥一定要用macro呢

我用下面的code, 但是出错,好像是参数类型传递错误
%macro derv(lambda);
%global dl;
%let temp1 = %sysfunc(exp(-&lambda));
%let dl = %sysevalf(10/&lambda + 25*&temp1/(1-&temp1) - 27.21);
%mend derv;
Data;
Lam_1 = 0.1;
%derv(Lam_1);
出错 (我把它改成 %derv(0.1) 就没有问题, 但是dl的值有问题,不知道用的时候,可不
可以这样用)
ERROR: A character operand was found in the %EVAL function or %IF condition
where a numeric operand is required.
我这儿需要把Lam_1转换成numeric type吗? 用什么函数可以转化?
另外, 对于Macro parameters, 好像只有输入参数,可以把参数设置成输出参数吗,要不
f*******e
发帖数: 7
26
来自主题: Statistics版 - 求助关于sas macro 中的if- then语句
the problem is not the %if, but the %let
%let constrain1 =%sysevalf(abs(%str(&marker1 - &constant)));
SAS doesn't know you are calling a function abs() here. try %sysfunc(abs()).
Good luck
p********a
发帖数: 5352
27
来自主题: Statistics版 - 发包子求大牛解SAS问题,急
纯数字怎么能做DATASET名字?
你的想法我感觉不行。应为SAS不能操作不存在的DATASET。中间会出错停止。
%macro a;
data all;
set %do i=1 %to 2000;%if %sysfunc(exist(a&i)) %then a&i; %end;;
run;
%mend;
%a;
l***a
发帖数: 12410
28
来自主题: Statistics版 - why this error in %if statement
if I replace "in (4,6)" with ****=4 or ****=6, the macro will run. does
this mean "in" logic is not valid in %if statement?

sysfunc(
p********a
发帖数: 5352
29
来自主题: Statistics版 - SAS 一问. 谢谢!
%let x=a b c d;
%let y=a b;
%let z=%sysfunc(tranwrd(&x, &y,));
%put &z;
x*******u
发帖数: 500
30
来自主题: Statistics版 - SAS 一问. 谢谢!
这个code不适用于a b c d次序是乱的。如果是下面这种情况,就不行。
%let x=a b c d;
%let y=a c;
%let z=%sysfunc(tranwrd(&x, &y,));
%put &z;
谢谢了
a********a
发帖数: 3176
31
来自主题: Statistics版 - SAS macro variable help
Thanks much! This is helpful, which pompted me to do something similar and
it worked:
1. get site count:
%let site_cnt=%sysfunc(countw(&impsints));
%put There are &site_cnt sites in the string "&impsints";
2. get site number to be indexed:
%do z= 1 %to &site_cnt;
%let realsite = %scan(&impsints, &z);
%let nsite_1 = %substr(&realsite, 5, 1);
%let nsite = %substr(&realsite, 5, 1);
%if &z>1 %then %do;
%let nsite = !%substr(&reals
S******y
发帖数: 1123
32
来自主题: Statistics版 - 下个定论吧,R和SAS比较
I once did a project (reporting application) using purely SAS macros, tons
of sysfunc and qsysfunc. It felt like programming in C, not limited to data
step boundaries.
I am now using R, Python, and SAS, whatever fits my problem. Meanwhile, I
am learning Weka
L*******d
发帖数: 38
33
来自主题: Statistics版 - SAS adv NEW Q23
One more question: Q12
Item 12 of 63 Mark item for review
Which title statement would always
display the current date?
A.
title "Today is: &sysdate.";
B.
title "Today is: &sysdate9.";
C.
title "Today is: &today.";
D.
title "Today is: %sysfunc(today(),worddate.)";
s*********r
发帖数: 909
34
来自主题: Statistics版 - 继续问个MACRO VARIABLE问题。。。
%sysfunc(left(&nvar))
w**********g
发帖数: 48
35
来自主题: Statistics版 - 请教 关于ADV真题第12题(更新)
我觉得A对啊,为什么不是A,B 而是D呢
我电脑跑出来是这样的,是不是我电脑用的破解版出问题啊
561 %put "today is %sysfunc(today(),worddate.)";
"today is August 7, 1993"
562 %put "today is: &sysdate.";
"today is: 07AUG10"
563 %put "today is: &sysdate9.";
"today is: 07AUG2010"
Item 12 of 63 Mark item for review
Which title statement would always
display the current date?
A.
title "Today is: &sysdate.";
B.
title "Today is: &sysdate9.";
C.
title "Today is: &today.";
D.
title "Today is: %sysfu
L***4
发帖数: 13
36
我的理解是LZ已经产生了一个巨大的sas data在WORK library里。最快的方法的是先找
到它的物理存储位置(%put %sysfunc(pathname(work));),然后移到另一目录, 耗时<0
.01second。
a*****3
发帖数: 601
37
怎么移到另一目录?

找: 到它的物理存储位置(%put %sysfunc(pathname(work));),然后移到另一目录, 耗
时<0: .01second。
h******e
发帖数: 1791
38
我用到是笨办法,一先判断a是否存在,用%sysfunc(exist(a))。如果yes,将其改名为
b。然后每得到一个a,就将其追加到b,用proc append。
h******e
发帖数: 1791
39
例如:
%if %sysfunc(exist(a)) %then %do;
proc append base = b data = a;run;
%end;
%else %do;
data b; set a; run;
%end;
p****8
发帖数: 50
40
来自主题: Statistics版 - sas adv 63题 12题
第12题答案是D,为啥A,B不对?
Item 12 of 63 Mark item for review
Which title statement would always
display the current date?
A.
title "Today is: &sysdate.";
B.
title "Today is: &sysdate9.";
C.
title "Today is: &today.";
D.
title "Today is: %sysfunc(today(),worddate.)";
o****o
发帖数: 8077
41
来自主题: Statistics版 - SAS Technical Interview Questions
ZT from :
http://www.globalstatements.com/sas/jobs/technicalinterview.htm
*****************************************
SAS Technical Interview Questions
You can go into a SAS interview with more confidence if you know that you
are prepared to respond to the kind of technical questions that an
interviewer might ask you. I do not provide the specific answers here, both
because these questions can be asked in a variety of ways and because it is
not my objective to help those who have little actual int... 阅读全帖
s******y
发帖数: 352
42
来自主题: Statistics版 - 请教用SAS的一个数据处理的问题
Your solution is very nice.
I would do the same thing as you proposed, if number of variables are less
than 10.
As to the warning message, you can suppress the warnings by using option
mergenoby=NOWARN.
you can do something like this.
1. save the current option setting.
%let oldop=%sysfunc(getoption(mergenoby));
2. run your datasteps
data XXXX;
...
...
run;
3. reset the options.
options mergenoby=&oldop;
o****o
发帖数: 8077
43
来自主题: Statistics版 - 请教一个SAS问题
libname y "c:";
%let path=%sysfunc(pathname(y));
filename getfiles pipe "dir/b /on &path.mas_*.sas";
data filenams;
infile getfiles length=l end=eof;
length filename $200;
input @;
input @1 filename $varying200. l;
filename=upcase(filename);
if eof then put filename=;
run;
D******n
发帖数: 2836
44
来自主题: Statistics版 - 新手问个问题 (转载)
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... 阅读全帖
l***a
发帖数: 12410
45
来自主题: Statistics版 - SAS: how to build a timer
哦,好像这样就行
%put %sysfunc(datetime(),datetime20.2);
h******e
发帖数: 1791
46
来自主题: Statistics版 - sas 代码问题
说起来也容易,去掉month的引号就行了,因为%sysfunc是一个macro function。
m********9
发帖数: 1985
47
来自主题: Statistics版 - 【包子】求问个简单sas macro问题
不是那么简单因为X 是个变量。
%macro avg/parmbuff;
proc sql noprint;
select x into : x separated by " "
from temp
where number<=7;
quit;
data temp1;
set temp;
where number<=7;
%do _a = 1 %to %eval(%sysfunc(count(&x, %bquote( ))) + 1);
%let i= %scan(&x, &_a, %str( )));
y=mean(a1-a&i);
output;
%end;
run;
%mend;


S*******1
发帖数: 251
48
来自主题: Statistics版 - greenhand asks a question on SAS Macro
%sysfunc; %qsysfunc
w*****r
发帖数: 92
49
来自主题: Statistics版 - SAS MACRO里的循环不work是怎么回事
macro code应该循环执行两次%step1 %step2,最后将结果输出到z_a
和z_b里, Step1 & 2是调用的比较复杂的code,单独运行没有问题。可是code怎么改也
不执行循环,最后只出来一个z_a.哪位前辈指点一二啊,谢谢了!
%let job=z;
%let name=a b;
%let count = %sysfunc(countw(&method));
%macro x;
%do i=1 %to &count;
%let m = %scan(&name, &i);
%let jobname = &job._&m;
%step1(jobname=&job, ...);
%step2(Jobname=&jobname, label=&m, ...);
%end;
%mend x;
用下面的code试了下就可以,难道是step1 2内部的问题?
%macro part1(jobname=, cov=);
data &job;
set eco;
keep &cov;
run;
%mend;
%macro part2(jobname=... 阅读全帖
s*******e
发帖数: 1385
50
来自主题: Statistics版 - 求助:一个SAS的小问题
%macro test;
proc sql;
select distinct firms into: firmvars separated by ' '
from yourdata;
quit;
%do i=1 %to %sysfunc(countw(&firmvars));
%let firmvar=%scan(&firmvars., &i., ' ');
data &firmvar.;
set yourdata;
where Firms="&firmvar.";
run;
%end;
%mend test;
%test
1 (共1页)