由买买提看人间百态

topics

全部话题 - 话题: symget
(共0页)
t****y
发帖数: 576
1
来自主题: Statistics版 - SAS advance Quiz 一问
我觉得题目并没有特别限定,a和d都对,a可能得不到想要得value但题目并没有说想给
price赋什么样的值啊
Which of the following statements correctly creates a DATA step variable
named Price and assigns to it the value of the macro variable daily_fee
during DATA step execution?
a.
price=&daily_fee;
b.
price=symget(daily_fee);
c.
price=symget(&daily_fee);
d.
price=symget("daily_fee");
p***r
发帖数: 920
2
来自主题: 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... 阅读全帖
f*****k
发帖数: 110
3
来自主题: Statistics版 - SAS help : The scope of macro variables
It seems the following link is only for prior's first observation.So any
reference for his/her second observation -- "If you want to use SYMGET to
input the value to the data set, then the
macro variable must be global"--? I just feel that it would be convenient if
SYMGET can also use local macro variable even though only under special
conditions. Thanks.
p***r
发帖数: 920
4
来自主题: Statistics版 - SAS help : The scope of macro variables
I think symget can only use global macro variables as I tried. And its kinda
of bugging that, using
%let var=;
would only give u a local macro variable, and when the macro is compiled and
the text unwrapped, &var will be deleted and you cannot call it using
symget when executing data step.
I really would like to know more about why and how.

if
f*****k
发帖数: 110
5
来自主题: Statistics版 - SAS help : The scope of macro variables
What if the data step where SYMGET is used is contained in a macro? There
would be a local table from which SYMGET can get values, I guess.

kinda
and
a********a
发帖数: 3176
6
来自主题: Statistics版 - put statement in macro
Thank you.
But timeline_length is not a macro variable - it is a regular var that has
values 1-300. How can I create a macro variable that has the same value? I
tried 'symget ' but it didn't work.
A*******s
发帖数: 3942
7
来自主题: Statistics版 - 一个sas macro variable的问题。
看看这个行不行
var=symget(cats('a',put(_N_, 2.)));

observation
f*******e
发帖数: 51
8
try this:
data countmiss;
input var1 var2 var3 var4 var5 var6;
cards;
0 0 0 0 0 1.2
0 0 0 0 5.8 4.7
58.8 0 0 30 0 33.3
100 0 0 100 0 66.6
;
run;
data _null_;
set countmiss;
array var(*) var1-var6;
call symput("list"||strip(_N_),"");
do i=1 to dim(var);
if var(i)>0 and var(i) <50 then do;
call symput("list"||strip(_N_),symget("list"||strip(_N_))||" "||"var"||strip
(i));
end;
end;
run;
%put &list1 &list2 &list3 &list4;
z****n
发帖数: 67
9
多谢楼上提醒,把楼上的code改成下面的就可以运行啦!
data countmiss;
input var1 var2 var3 var4 var5 var6;
cards;
0 0 0 0 0 1.2
0 0 0 0 5.8 4.7
58.8 0 0 30 0 33.3
100 0 0 100 0 66.6
;
run;
data _null_;
set countmiss;
array v(*) var1-var6;
call symput("list"||compress(_N_),"");
do i=1 to dim(v);
if 0< v(i) <50 then do;
call
symput("list"||compress(_N_),left(trim(symget("list"||compress(_N_))||"
"||"
var"||compress(i))));
end;
end;
run;
%put list1=&list1 ;
%put list2=&list2 ;
%put list3=&list3 ;
%put list4=&lis
D******n
发帖数: 2836
10
来自主题: 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... 阅读全帖
z*******m
发帖数: 87
11
来自主题: Statistics版 - 请教个macro的问题
大概是这样的。用if then语句在一系列的year中找到了我想要的year,比如1995, 然
后需要用到table中的variable pt1995。如果找到的变量是1994,就要用到变量pt1994。
我尝试了%let,symget(), 貌似都不行。
year pt1992 pt1993 pt1994 pt1995 pt1996
1992 12 11 13 12 10
1993 11 10 9 3 4
1991 10 8 13 15 16
.....
不知道我说清楚了否。
s***c
发帖数: 1664
12
来自主题: Statistics版 - 问个sas小问题: 赋值macro variable
变量age, 我想把它的最小值和最大值赋值给两个macro variable, 然后再做histogram
的时候调用他们.
proc means data=data max min ;
var age;
OUTPUT OUT=stats1 min(age)=min_age max(age)=max_age;
run;
data _NULL_;
set stats1;
call symputn("MIN_AGE", min_age);
call symputn("MAX_AGE", max_age);
run;
proc sgplot data=data;

histogram age / binstart=%symget('MIN_AGE') binwidth=('MAX_AGE'-'MIN
_AGE')/10;
run;
首先symputn不能用,那怎么把numeric值赋给macro variable呢? 然后在proc 里面
怎么resolve这两个macro variable, binstart是MIN_AGE, binwidth... 阅读全帖
s***c
发帖数: 1664
13
来自主题: Statistics版 - 问个sas小问题: 赋值macro variable
it works,谢谢了。 一定要用proc sql吗,在data step里不可以把numeric赋值给
macro variable?还有symget是用在data step里,proc里面用&?
e*********5
发帖数: 151
14
来自主题: Statistics版 - 问个sas小问题: 赋值macro variable
我觉得你在data step加一行call symput("binwd", (max_age -min_age / 10));就好
了。 主意我用的symput不是symputn,我不了解后者
另外我不明白你为啥用symget,呼叫macro不是应该都用&么?比如&max_age,不管data
step还是sql.这个字符型数值型没关系吧
s***c
发帖数: 1664
15
来自主题: Statistics版 - 问个sas小问题: 赋值macro variable
对的,,,用call symput就好了, 不用赋值成numeric, character就好了,然后在
proc里面用& resolve, symget在data step里面只有一些特殊情况才用。明白了

data
(共0页)