由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - How to the macro regression with if?
相关主题
一个关于macro的问题,多谢。regression problem - go confused
SAS Regression Macro 问题请教 (有包子)请教一道SAS MACRO编程的问题。怎么都不明白。谢谢
一道ADV 130 题目help need for SAS macro
proc iml help!SAS format 的问题
SAS ADVANCED 一道题求助SAS Macro 问题请教 。。。
Need advice on SAS macro debugging请教一个SAS Macro问题。谢谢
一个常见的问题a sas adv question
问一些sas的问题请帮忙看3道SAS题。
相关话题的讨论汇总
话题: macro话题: regression话题: data1话题: regre话题: variable
进入Statistics版参与讨论
1 (共1页)
c**********e
发帖数: 2007
1
Suppose that I have a data set data1, with numerical variables
x, y, z. I would like to do regression y=x if a macro
variable is "a" and do z=x y if the macro variable is not
"a". The following does not work well. How to do it?
%macro regre(var);
%if "&var."="a" %then %do;
proc reg data=data1;
model y=x;
run;
%end;
%else %do;
proc reg data=data1;
model z=x y;
run;
%end;
%mend;
%regre(a);
%regre(b);
o******6
发帖数: 538
2
It is not necessary to use "if then", just create two macro variable which
are dependent variable and independent variable, separately.

【在 c**********e 的大作中提到】
: Suppose that I have a data set data1, with numerical variables
: x, y, z. I would like to do regression y=x if a macro
: variable is "a" and do z=x y if the macro variable is not
: "a". The following does not work well. How to do it?
: %macro regre(var);
: %if "&var."="a" %then %do;
: proc reg data=data1;
: model y=x;
: run;
: %end;

c**********e
发帖数: 2007
3
Thanks. Your approach would work. But my real problem is to
work on two proc's based a macro variable value. To make it
work, I have to make the above example work with the if else.

【在 o******6 的大作中提到】
: It is not necessary to use "if then", just create two macro variable which
: are dependent variable and independent variable, separately.

o******6
发帖数: 538
4
%macro regression(dep=,indep=);
proc reg data=data1;
model &dep=&indep;
run;
%mend;
%regression(dep=y,indep=x);
%regression(dep=z,indep=x y);

【在 c**********e 的大作中提到】
: Thanks. Your approach would work. But my real problem is to
: work on two proc's based a macro variable value. To make it
: work, I have to make the above example work with the if else.

w***z
发帖数: 28
5
u code is ok for me.
what did u mean when u said "not work well"?
o******6
发帖数: 538
6
Yes, the code works but I don't think it is good if I understand what he
said.

【在 w***z 的大作中提到】
: u code is ok for me.
: what did u mean when u said "not work well"?

c**********e
发帖数: 2007
7
Thank you for your input.
I have made my original code compiled. But it seems that,
from MPRINT, the part in %if ... %do; ... %end; is ignored.
It is really weird.

【在 o******6 的大作中提到】
: Yes, the code works but I don't think it is good if I understand what he
: said.

1 (共1页)
进入Statistics版参与讨论
相关主题
请帮忙看3道SAS题。SAS ADVANCED 一道题求助
请教:sas 循环Need advice on SAS macro debugging
sas question一个常见的问题
macro variable 的问题问一些sas的问题
一个关于macro的问题,多谢。regression problem - go confused
SAS Regression Macro 问题请教 (有包子)请教一道SAS MACRO编程的问题。怎么都不明白。谢谢
一道ADV 130 题目help need for SAS macro
proc iml help!SAS format 的问题
相关话题的讨论汇总
话题: macro话题: regression话题: data1话题: regre话题: variable