由买买提看人间百态

topics

全部话题 - 话题: symput
首页 上页 1 2 3 (共3页)
h******e
发帖数: 1791
h******e
发帖数: 1791
2
可不可以说得详细一点,谢谢。
h****o
发帖数: 119
3
来自主题: Statistics版 - 一道ADV 130 题目
非常感谢! 但SAS ONLINE TUTOR SAYS:
You can create local macro variables with
• parameters in a macro definition
• a %LET statement within a macro definition
• a DATA step that contains a SYMPUT routine within a macro
definition
• a SELECT statement that contains an INTO clause in PROC SQL
within a macro definition
• a %LOCAL statement.
不是应该符合第3条的吗?
l**********9
发帖数: 148
4
来自主题: Statistics版 - 一道ADV 130 题目
其实这个问题是这样的,如果没有%one()这个语句,也就是说这个macro的代码没有被
执行,那么里面定义的变量就是local的,只能被这个macro内部的代码调用,但是加上
了%one()这个语句,代码被执行了,那么此时symput所初始化的变量就变成了全局的..
所以两种说法都有道理,在这道题里面应该是全局变量...不过如果代码没有执行的话
sas会给变量分配内存空间么?不太清楚..谁能告诉我sas底层用什么写的...
a*****3
发帖数: 601
5
来自主题: Statistics版 - 请问SAS advanced macro global 和local
symput 应该产生global 还是local的?谁翻翻书。
反正
symputX(,,'G')产生global,
symputX(,,'L')产生local.
a*****3
发帖数: 601
6
来自主题: Statistics版 - 请问SAS advanced macro global 和local
"a DATA step that contains a SYMPUT routine within a macro definition"
说的是macro定义在data步里面吧? 不适用于你的这个例子吧?
l**********9
发帖数: 148
7
来自主题: Statistics版 - 一个不理解的SAS program
.....动物园多和谐
我想LZ的意思是,_N_在data step执行完后应该会被自动drop掉啊,这样的话就没法被
call symput调用了啊...其实不是这样的,_n_在data step执行完后只是被从数据集中
drop掉了,而不是消失了,这个你debug一下就明白了,用list的话看到输出数据集中
没有_n_,但是用describ能看到_n_
a****g
发帖数: 8131
8
来自主题: Statistics版 - how to define a macro?
%let
proc sql select into
symput
%local
%global
y****d
发帖数: 432
9
来自主题: Statistics版 - 【分享】SAS2010全球论坛文章合集
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
前面说明:
需要的童鞋请到我的签名档的博客查找!谢谢!发E-mail太累了!
觉得有价值的话可以顶一下,以便更多的人看到!谢谢!
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
SAS2010全球论坛文章
1-10
Getting Connected to Your Data with SAS/CONNECT®
A Robust and Flexible Approach to Automating SAS® Jobs Under UNIX
Using SAS® Output Delivery System (ODS) Markup to Generate Custom
PivotTable and PivotChart Reports
Creating Easily Reusable and Extensible Processes: Code That Thinks for
Itself
ODS HTML Evolution, HTML that scrolls, panels, ... 阅读全帖
i******n
发帖数: 839
10
来自主题: Statistics版 - 如何判断一个dataset是不是空的?
DATA EMPTY;
LENGTH CHART1 $10.;
/* DO I=1 TO 9;
CHART1="MITBBS"; OUTPUT;
END;*/
RUN;
DATA EMPTY;
SET EMPTY;
IF CHART1="MITBBS";
RUN;
DATA _NULL_;
IF _N_ = 0 THEN SET EMPTY NOBS=NOBS;
CALL SYMPUT ("SIZE", PUT(NOBS, BEST.));
RUN;
%PUT &SIZE;
s*****9
发帖数: 285
11
来自主题: Statistics版 - ADV SAS 63题中的第23题
symput两个variables的时候一起call,要在前面多加一个Ampersand.
r******m
发帖数: 369
12
来自主题: Statistics版 - SAS ADVANCED 一道题求助
At the start of a new SAS session, the following program is submitted:
%macro one;
data _null_;
call symput('proc','means');
run;
%mend;
%one()
What is the result?
A. The macro variable PROC is stored in the local symbol table.
B. The macro variable PROC is stored in the global symbol table.
C. The macro variable PROC is stored in the sas catalog work.sasmacr.
D. The program fails to execute because PROC is a reserved word.
答案选B,怎么会呢?应该是A吧,可是我试了一下code真的是B啊,为什么啊?
d******9
发帖数: 404
13
来自主题: Statistics版 - SAS ADVANCED 一道题求助
B. The macro variable PROC is stored in the global symbol table.
It is correct.
When we use CALL SYMPUT to create a macro variable, please be noted it is
assigned to the MOST LOCAL, NON-EMPTY symbol table.
In this case, the macro ONE is empty, the created macro variable can not be
assigned to it, and then it goes to Global, instead.
r******m
发帖数: 369
14
来自主题: Statistics版 - SAS ADVANCED 一道题求助
baicai和dido都是对的
假如我把codes改成
%macro one;
%let guess=random;
data _null_;
call symput('proc','means');
run;
%mend;
%one
这里的proc就是local macro variable了。
s******r
发帖数: 1524
15
来自主题: Statistics版 - SAS ADVANCED 一道题求助
I can not remember clearly. It looks if you create some local macro
variables or dataset, then symput would create local macro variables.
Otherwise it should be global.
d******9
发帖数: 404
16
来自主题: Statistics版 - SAS DATA PROCESSING 问题
使用 Macro 可以不?
Call symput("PIN", SchoolID);
SchoolPIN="school&PIN";
a********i
发帖数: 205
17
来自主题: Statistics版 - one little SAS question
here is the SAS code:
data _null_;
if 0 then set &data nobs = count;
call symput('numobs', left(put(count, 8.)));
stop;
run;
I don't know what is the meaning of "if 0 then..."
can some big OX to explain it?
Thanks so much
l*****8
发帖数: 483
18
来自主题: Statistics版 - one little SAS question
网上找的
'If 0 then' prevents the SET statement from executing ( i.e. reading obs ).
However, the data step NOBS variable is set at compile time when data set
header information is read, hence available to the SYMPUT statement.
p*******r
发帖数: 1951
19
来自主题: Statistics版 - SAS question
table1是原始数据,table2是变量说明。
data _null_;
set table2 end=eof;
length temp $200.;
if type = 1 then temp=catx(" ",temp,var);
retain temp;
if eof then call symput('vars', temp);
run;
data pick(keep=id &vars);
set table1;
run;
r******m
发帖数: 369
20
其实我的背景是非典型啊,有绿卡,有金融背景,口语不错比较能吹,所以优势挺大的。
不过我有一年没有工作,书本知识基本忘光,有gap,一般就跟人家说照顾小孩了,大
多数人表示理解。
我考了SAS两个证书,基本上每个复习了40天把,每个都把一千页左右的prep guide从
头到尾全看了,当然再加上真题拿到证书是轻而易举。
考完了就开始撒简历,主要是career builder, dice, monster几个网站。这几个感觉
dice最好,得到的repsonse比较多,其次是career builder,最差的是monster和
efinancialcareers,前者工作少,后者绿卡广告很多。基本都是猎头或者consulting
公司的HR在联系我。
现在主要说一下我的两个offer的面经。
第一个其实是熟人让我看linkedin上的sas professional job board的listing,我投
了才拿到的,所以linkedin也是很有用。公司是个金融监管机构,contractor job, 主要用
SAS和SQL。共两轮面试,第一轮电话,就问了一些left join, 什么... 阅读全帖
b****u
发帖数: 67
21
来自主题: Statistics版 - sas macro 问题,
1. 请问b为啥不对呀 ?? 谢谢
%macro printdsn(dsn,vars);
%if &vars= %then %do;
proc print data=&dsn;
title "Full Listing of %upcase(&dsn) data set";
run;
%end;
%else %do;
proc print data=&dsn;
var &vars;
title "Listing of %upcase(&dsn) data set";
run;
%end;
%mend;
a. %printdsn(sasuser.courses, course_title days);
b. %printdsn(dsn=sasuser.courses, vars=course_title days)
c. %printdsn(sasuser.courses, course_title days)
d. %printdsn(sasuser.courses, cours... 阅读全帖
d******9
发帖数: 404
22
来自主题: Statistics版 - sas macro 问题,
1.If you want to use keyword macro parameters, you need declare them in the
macro definition first.
However, the definition here:
%macro printdsn(dsn,vars);
is not correct, it define the positional parameters.
If you want to use b, then you should define macro like this:
%macro printdsn(dsn=,vars=);
2. data _null_;
set sasuser.courses;
call symput('class', course_title);
run;
variable class是local 还是global ne ?
it is global, because it is defined in open code.
b****u
发帖数: 67
23
来自主题: Statistics版 - sas macro, proc sql 问题
问题一
看不出毛病呀, 答案D也不work 呀?
85. Given the SAS data set OURDATA:
OURDATAObsproduct sales
1 OR 1000
2 NE 1200
3 MM 1450
After submitting a SAS program, the following is written to the SAS log:
70 %macro a;
71 data _null_;
72 set ourdata;
73 call symput('product'!!left(_n_), product);
74 run;
75 %if &product1 = OR %then %do;
76 proc means data = ourdata;
77 run;
78 %end;
79 %mend;
80 %a
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
73:66
NOTE: Th... 阅读全帖
k*******a
发帖数: 772
24
来自主题: Statistics版 - SAS 随机选择的问题
你可以用 call symput 放到一个macro variable里面
s*********r
发帖数: 909
25
发信人: papertigra (长工胖头猪), 信区: Statistics
标 题: CRO SAS Interview questions
发信站: BBS 未名空间站 (Fri Feb 26 21:12:00 2010, 美东)
http://www.sas9.blogspot.com/
SAS Programer Position
1. What kind of AE tables are there?
2. What difference between proc means and freq?
3. What does run statement mean?
4. What is ITT? What assessment in ITT definition is?
5. Which procedure can produce standard deviation of a variable?
6. What do put and input functions do?
7. How to validate your program?
8. How to identify... 阅读全帖
p***r
发帖数: 920
26
来自主题: Statistics版 - SAS help : The scope of macro variables
Recently, aware many problems when programming macros. The scope of macro
variables (global/local) are sometimes in in-explicit to me. It there any
articles systematically covering this topic.
1. In a macro, if you use SYMPUT in data step, the macro variable you
created is global.
2. If you want to use SYMGET to input the value to the data set, then the
macro variable must be global. Then here is the problem, locally produced
macro variable will disappear, and will not be an valid argument durin... 阅读全帖
l*****8
发帖数: 483
27
来自主题: Statistics版 - SAS help : The scope of macro variables
第一个已经先有了一个local num, local table 不是空的,所以再用symput,就都是
local.
第二个因为local table是空的,生成得就是globle.
b*u
发帖数: 30
28
来自主题: Statistics版 - SAS help : The scope of macro variables
Both examples do NOT work in my PC. Can you tell me the reason?
LOG:
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted
string,
a numeric constant, a datetime constant, a missing value,
arrayname, (, ), +,
',', -, INPUT, NOT, OF, PUT, ^, _NEW_, ~.
ERROR 159-185: Null parameters for SYMPUT are invalid.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
j*********a
发帖数: 232
29
来自主题: Statistics版 - 急问一个call symput问题(SAS)
it works! Thanks!
b********6
发帖数: 14
30
来自主题: Statistics版 - sas 代码问题
Try symput?
l*********s
发帖数: 5409
31
来自主题: Statistics版 - SAS call symput question
No, this is a scope issue.
In the open data step, the sss is defined in the global table, but once you
bracket it, now it lives in the local table of the macro, and no longer
accessible from the outside.
The solution is declare it as global in the macro, before the data step.
n****u
发帖数: 229
32
来自主题: Statistics版 - SAS call symput question
转帐完成
转给用户:scimitar,现金(伪币):20,
n**m
发帖数: 156
33
来自主题: Statistics版 - SAS call symput question
you are right. I didn't read it through. things learned. thanks.

you
k*******a
发帖数: 772
34
data _null_
然后用 call symput
L****n
发帖数: 3545
35
来自主题: Statistics版 - 求助,SAS ADV 130 中94
Local macro variables cane be created with
the parameters in a macro definition
a %LET statement within a macro definition
a DATA step that contains a SYMPUT routine within a macro definition
a DATA step that contains a SYMPUTX routine within a macro definition
(New with SAS 9)
a SELECT statement that contains an INTO clause in PROC SQL within a
macro definition
a %LOCAL statement.
http://studysas.blogspot.com/2010/09/how-to-create-global-or-lo
s*********e
发帖数: 944
36
来自主题: Statistics版 - 请问SAS ADV 130中74 和80题
74. The following SAS program is submitted:
%macro one(input);
%two
%put the value is &date;
%mend;
%macro two;
data _null_;
call symput('date', '12SEP2008');
run;
%mend;
%let date = 31DEC2006;
%one(&date)
What is the result when the %PUT statement executes?
A.A macro variable DATE with the value 12SEP2008 is retrieved from the
global symbol table.
B.A macro variable DATE with the value 31DEC2006 is retrieved from the
global symbol table.
C.A macro variable DATE with the value 12SEP2008 is retri... 阅读全帖
s******r
发帖数: 1524
37
data score;
do score=1 to 88;
output;
end;
run;
%macro subgrp(set=,var=, grp=);
proc sort data=&set;by &var;run;
data _null_;set &set end=eof;
if eof then call symput ('total',_n_);
run;
%let step=%eval(&total/&grp);
%if %eval(&step*&grp) < &total %then %let step=%eval(&step+1);
%do i =0 %to %eval(&grp-1);
%let first_obs=%eval(&i*&step+1);
%let obs=%eval(&first_obs+&step -1);
data &set&i;set &set(firstobs=&first_obs obs=&obs);run;
%end;
%mend;
%subgrp(set=score,var=score, grp=5);
bz pls.
h********o
发帖数: 103
38
Try this:
============
data test;
do x = 99 to 1 by -1;
output;
end;
run;
%macro split(inputdata, N, var);
proc sort data = &inputdata;
by &var;
run;
data _null_;
if 0 then set &inputdata nobs = count;
call symput("numobs", put(count,8.));
run;
%let m = %sysevalf(&numobs/&N, ceil);
%do i = 1 %to &N;
data test&i;
set &inputdata;
if %eval(&m*(&i-1)) < _N_ <= %eval(&m*&i);
run;
%end;
%mend;
%split(test,5,x);
t*****8
发帖数: 157
39
来自主题: Statistics版 - 问大家一个Macro的问题
程序如下:
data _null_;
set cnt;
i+1;
ii=left(put(i,2.));
call symput('name'||ii,clinname);
%put &&name&i;
run;
log:
WARNING: Apparent symbolic reference I not resolved.
WARNING: Apparent symbolic reference NAME not resolved.
WARNING: Apparent symbolic reference I not resolved.
&name&i
但是我加了LOOP在下面就可以了,为什么?
%do i=1 %to &sqlobs;
%put &&name&i;
%end;
A****t
发帖数: 141
40
来自主题: Statistics版 - sas question!!!
用macro会方便一点
data _null_;
length filename $ 10;
input filename $;
call symput('y'||left(_n_), filename);
datalines;
a_20120101
a_20120102
a_20120105
a_20120106
b_20120107
;
run;
%put &y1 &y2 &y3 &y4 &y5;
g****8
发帖数: 2828
41
来自主题: Statistics版 - 【包子】求问个简单sas macro问题
我说的是call symput这一步。
你不加给变量加个_N_, 那data step每次都是用取到的最后一行的那个值。
你可以去试试,我说的对不对。
我又没有说整个data step。
不要想当然哟。
s*******2
发帖数: 499
42
来自主题: Statistics版 - 请教SAS adv 题库一道macro题
The following SAS program is submitted: %macro one(input);
%two;
%put the value is &date; %mend;
%macro two; data _null_;
call symput('date','12SEP2008'); run;
%mend;
%let date=31DEC2006;
%one(&date)
What is the result when the %PUT statement executes.?
A. A macro variable DATE with the value 12SEP2008 is retrieved from the
local symbol table for the ONE macro
B. A macro variable DATE with the value 12SEP2008 is retrieved from the
local symbol table for the TWO macro
C. A macro variable... 阅读全帖
p*******r
发帖数: 1951
43
来自主题: Statistics版 - 请教SAS adv 题库一道macro题
因为call symput定义的是global macro variable。
n****e
发帖数: 226
44
来自主题: Statistics版 - 请教SAS adv 题库一道macro题
因为 %two 没有 parameter,所以 local symbol table 为空
所以 call symput 产生的macro variable 被放在 global symbol table
n****e
发帖数: 226
45
来自主题: Statistics版 - 请教SAS adv 题库一道macro题
这个也有道理,&date 已经被定义成了 global macro variable
%two 里的 call symput 就是把它 update 了一下?
x**********0
发帖数: 163
46
来自主题: Statistics版 - One question about %put
when you use the SYMPUT routine to create a macro variable in a data step,
the macro variable is not actually created and assigned a value until the
data step is executed. Therefore you can not reference a macro variable
within the same data step. just place the %put after the data step.
z**********i
发帖数: 12276
47
来自主题: Statistics版 - SAS初级问题请教
That should be not difficult to create a macro variable either use data step
or sql.
Such as call symput in data step.

Now
of
s*******e
发帖数: 1385
48
来自主题: Statistics版 - 请教个macro的问题
Yes, call symput('year',put(year,z4.))
c****i
发帖数: 228
49
来自主题: Statistics版 - sas题目恳请前辈指点!!
call symput
w*******l
发帖数: 18
50
来自主题: Statistics版 - sas题目恳请前辈指点!!
%let rc = high;
change to
call symput(rc,'high');
首页 上页 1 2 3 (共3页)