由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - SAS macro question
相关主题
请帮忙看3道SAS题。SAS初级问题请教
请教一个SAS画图求SAS code,有包子
请问SAS advanced macro global 和local请教一道sas 题
help: proc logisticQuestion Proc GENMOD
SAS ADVANCED 一道题求助请教一下proc ttest, weighted data
SAS Macro 问题请教 。。。问个sas编程的题
求助,SAS ADV 130 中94问几题sas adv, 多谢了!
请教一个SAS问题:怎样平均地把obs从小到大分成几个Group?请教这种freq 该用什么code算(sas)?Thanks!
相关话题的讨论汇总
话题: sas话题: model话题: run话题: data话题: proc
进入Statistics版参与讨论
1 (共1页)
s********e
发帖数: 255
1
Dear all,
I’m having a problem writing a SAS macro.
Briefly, I would like to store values of a variable from a dataset to a
macro variable, and use those values in the regression model.
For example, the B variable in the following model is a continuous model and
I would like to update the &I in the following model with a series of
values of B, such as 2, 6, 9, 13, etc, one for each time.
PROC RLOGIST DATA=FINAL FILETYPE=SAS;
NEST SDMVSTRA SDMVPSU;
WEIGHT WTDR2D4YR;
CLASS A;
MODEL Y= A B A*B;
PREDMARG A*B / B=(&I);
PRED_EFF B=(-1 1)*A=(1) / A=(&I);
RUN;
So I tried the following way by using CALL SYMPUT. However, it turned out to
be that only the last observation (value) of B will be used, rather than
using the values one by one. Could someone please help me out? Thank you
very much.
DATA _NULL_;
CALL SYMPUT (“I”, B);
PROC RLOGIST DATA=FINAL FILETYPE=SAS;
NEST SDMVSTRA SDMVPSU;
WEIGHT WTDR2D4YR;
CLASS A;
MODEL Y= A B A*B;
PREDMARG A*B / B=(&I);
PRED_EFF B=(-1 1)*A=(1) / A=(&I);
RUN;
RUN;
Z****B
发帖数: 195
2
那个symput 中 I 只有一个值 , 去掉引号试试。 不行就 loop 一下吧
s********e
发帖数: 255
3
Thank you for the reply. Please bear with me; I cannot type in Chinese here.
I did try a loop, which was like:
DATA _NULL_;
DO j = 1 TO 5;
CALL SYMPUT (“I”, B);
PROC RLOGIST DATA=FINAL FILETYPE=SAS;
NEST SDMVSTRA SDMVPSU;
WEIGHT WTDR2D4YR;
CLASS A;
MODEL Y= A B A*B;
PREDMARG A*B / B=(&I);
PRED_EFF B=(-1 1)*A=(1) / A=(&I);
RUN;
END;
RUN;
But it didn't work, either.

【在 Z****B 的大作中提到】
: 那个symput 中 I 只有一个值 , 去掉引号试试。 不行就 loop 一下吧
s********e
发帖数: 255
4
Which 引号 do you mean?

【在 Z****B 的大作中提到】
: 那个symput 中 I 只有一个值 , 去掉引号试试。 不行就 loop 一下吧
Z****B
发帖数: 195
5
You should deal with it in the symput if you do loop
Z****B
发帖数: 195
6
I 的引号

【在 s********e 的大作中提到】
: Which 引号 do you mean?
s********e
发帖数: 255
7
Sorry, I don't quite get you. Would you mind writing the code down for me?
Thank you very much.

【在 Z****B 的大作中提到】
: You should deal with it in the symput if you do loop
Z****B
发帖数: 195
8
How about this one if you need run 5 times:
%macro log(I)
PROC RLOGIST DATA=FINAL FILETYPE=SAS;
NEST SDMVSTRA SDMVPSU;
WEIGHT WTDR2D4YR;
CLASS A;
MODEL Y= A B A*B;
PREDMARG A*B / B=(&I);
PRED_EFF B=(-1 1)*A=(1) / A=(&I);
RUN;
%mend;
%log(value1)
%log(value2)
and so on.
s******8
发帖数: 102
9
%macro for_u;
proc sql;
select distinct b into: allb separated by ' '
from final;
%let nb=&sqlobs;
quit;
%do j=1 %to &nb;
%let I=%scan(&allb,&j);
PROC RLOGIST DATA=FINAL FILETYPE=SAS;
NEST SDMVSTRA SDMVPSU;
WEIGHT WTDR2D4YR;
CLASS A;
MODEL Y= A B A*B;
PREDMARG A*B / B=(&I);
PRED_EFF B=(-1 1)*A=(1) / A=(&I);
RUN;
%end;
%mend
%for_u;
1 (共1页)
进入Statistics版参与讨论
相关主题
请教这种freq 该用什么code算(sas)?Thanks!SAS ADVANCED 一道题求助
请教 如何用macro variabe 传递数值?SAS Macro 问题请教 。。。
一道ADV 130 题目求助,SAS ADV 130 中94
如何判断一个dataset是不是空的?请教一个SAS问题:怎样平均地把obs从小到大分成几个Group?
请帮忙看3道SAS题。SAS初级问题请教
请教一个SAS画图求SAS code,有包子
请问SAS advanced macro global 和local请教一道sas 题
help: proc logisticQuestion Proc GENMOD
相关话题的讨论汇总
话题: sas话题: model话题: run话题: data话题: proc