由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - SAS help : get macro variables as an string but not character variable.
相关主题
SAS code help needed: multiple do loops do not return what is expectedSAS问题请教
急问这个SAS的code该怎么写SAS问题再请教
问个 UNIX 系统下的Sas Macro问题SAS Macro 问题请教 。。。
请教SAS adv 题库一道macro题Re: SAS help : How to use Macro to select procedurs
急问一个SAS 的常见问题help. sas macro
【调查】你的SAS Code做indent吗?一个笨笨的R问题
今儿过了SAS Advanced+机经sas 代码问题
急问:SAS batch submission with macro variable请问SAS ADV 130中74 和80题
相关话题的讨论汇总
话题: formula话题: macro话题: data话题: sas话题: run
进入Statistics版参与讨论
1 (共1页)
p***r
发帖数: 920
1
data set TEMP is like this
A B Formula
----------------------------
1 2 A*B
.....
wanna call the value in formula column as an string calculate the value.
such as
data TEMP2;
set TEMP;
cost= ????; *Here is what I need do input according to formula A*B;
run;
Any one can help?
d*******o
发帖数: 493
2
--------------Macro-------------
regular expression --> PROC FCMP
--------------Macro-------------
p***r
发帖数: 920
3
I don't get it

【在 d*******o 的大作中提到】
: --------------Macro-------------
: regular expression --> PROC FCMP
: --------------Macro-------------

D******n
发帖数: 2836
4
if u just have limited formula ,write "if and then"s to do it.

【在 p***r 的大作中提到】
: data set TEMP is like this
: A B Formula
: ----------------------------
: 1 2 A*B
: .....
: wanna call the value in formula column as an string calculate the value.
: such as
: data TEMP2;
: set TEMP;
: cost= ????; *Here is what I need do input according to formula A*B;

p***r
发帖数: 920
5
I can do that way, but what if there is 100 formulas, just curious how to
output as neither character nor numeric value but as string executable.

【在 D******n 的大作中提到】
: if u just have limited formula ,write "if and then"s to do it.
s*********e
发帖数: 1051
6
i have written the similar code before but am just curious to see other more
elegant solution :-)
A*******s
发帖数: 3942
7
data test;
input A B formula $;
cards;
23 12 A*B
75 2 A-B
6 7843 A/B
74 5 A**B
;
run;
data _null_;
set test end=eof;
if _N_=1 then call execute("data test2;");
call execute("i="||_N_||"; set test point=i; result="||formula||";
output;");
if eof then call execute("stop; drop i; run;");
run;
s*********e
发帖数: 1051
8
this is better than mine. i used macro.

【在 A*******s 的大作中提到】
: data test;
: input A B formula $;
: cards;
: 23 12 A*B
: 75 2 A-B
: 6 7843 A/B
: 74 5 A**B
: ;
: run;
: data _null_;

D******n
发帖数: 2836
9
This trick is actually using Macro facility in the background.

【在 s*********e 的大作中提到】
: this is better than mine. i used macro.
D******n
发帖数: 2836
10
this seems faster, but only applicable when the number of vars are small.
data _null_;
set test end=eof;
if _N_=1 then call execute("data test3;");
call execute("A="||A||";B="||B||";result="||formula||";output;");
if eof then call execute(" run;");
run;

【在 A*******s 的大作中提到】
: data test;
: input A B formula $;
: cards;
: 23 12 A*B
: 75 2 A-B
: 6 7843 A/B
: 74 5 A**B
: ;
: run;
: data _null_;

l******r
发帖数: 12
11
A simple one
data have;
input a b formula $;
datalines;
2 3 a*b
5 56 a-b
;
run;
data _null_;
set have;
call symputx("formula",formula);
run;
data need;
set have;
d=&formula.;
run;
p***r
发帖数: 920
12
This one not work, but actually provide a very good hint to what I want.
Thanks

【在 l******r 的大作中提到】
: A simple one
: data have;
: input a b formula $;
: datalines;
: 2 3 a*b
: 5 56 a-b
: ;
: run;
: data _null_;
: set have;

1 (共1页)
进入Statistics版参与讨论
相关主题
请问SAS ADV 130中74 和80题急问一个SAS 的常见问题
how to use first.var in sas macro?【调查】你的SAS Code做indent吗?
how to combine characters and numric variable in "where" clause by SAS?urgent!今儿过了SAS Advanced+机经
how to make this macro work, thanks急问:SAS batch submission with macro variable
SAS code help needed: multiple do loops do not return what is expectedSAS问题请教
急问这个SAS的code该怎么写SAS问题再请教
问个 UNIX 系统下的Sas Macro问题SAS Macro 问题请教 。。。
请教SAS adv 题库一道macro题Re: SAS help : How to use Macro to select procedurs
相关话题的讨论汇总
话题: formula话题: macro话题: data话题: sas话题: run