楼主: karenlvsas
1726 5

求高手debug [推广有奖]

  • 0关注
  • 1粉丝

本科生

86%

还不是VIP/贵宾

-

威望
0
论坛币
84 个
通用积分
0.3600
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
240 点
帖子
68
精华
0
在线时间
122 小时
注册时间
2011-8-20
最后登录
2016-11-26

8论坛币
程序如下:(运行错误,求高手指导!)
%macro EqWBinn (DSin, XVar, Nb, XBVar, DSout, DSMap);
proc sql noprint;
        select max(&XVar) into: Vmax from &dsin;
        select min(&XVar) into: Vmin from &dsin;
run;
quit;

%let bs=%sysevalf((&Vmax-&Vmin)/&Nb);

data &dsout;
set &dsin;
        %do i=1 %to &Nb;
        %let Bin_U=%sysevalf(&Vmax+&Vmin);
        %let Bin_L=%sysevalf(&Bin_U-&bs);
        %if &i=1 %then
                %do;
                if &Xvar>=&Bin_L and &Xvar<=&Bin_U then &XBvar=&i;
                %end;
        %else %if &i>1 %then
                %do;
                if &Xvar>&Bin_L and &Xvar<=&Bin_U then &XBvar=&i;
                %end;
        %end;
run;

proc sql noprint;
        create table &DSMap (BinMin num, BinMax num, BinNo num);
        %do i=1 %to &Nb;
        %let
        Bin_U=%sysevalf(&Vmin+&i*&Bs);
        %let
        Bin_L=%sysevalf(&Bin_U-&Bs);
                insert into &DSMap;
        values(&Bin_L,&Bin_U,&i);
                %end;
        quit;
%mend;

%let DSin=sashelp.cars;
%let DSout=test1;
%let XVar=Horsepower;
%let Nb=428;
%let XBVar=Horsepower_b;
%let DSMap=test1map;

%EqWBinn(&DSin, &XVar, &Nb, &XBVar, &DSout, &DSMap);

proc chart data=test1;
vbar Horsepower_b;
run;


关键词:debug bug 求高手 proc sql Select
沙发
teihohou 发表于 2014-9-14 23:52:21 |只看作者 |坛友微信交流群
proc sql 没有run;
其他的太复杂,需要好好看

使用道具

藤椅
sas9.4 发表于 2014-9-15 17:04:56 |只看作者 |坛友微信交流群
data 步里面不能用%let

使用道具

板凳
jingju11 发表于 2014-9-19 03:03:49 |只看作者 |坛友微信交流群
Two things need to be attended as per below:
(1)  error
insert into &DSMap;
remove the ; at end
(2) logic problem
i bet the conditions in data-step should be associated with step &i. You need to think about the logic here.

JingJu

使用道具

报纸
neoliberals 发表于 2019-6-25 19:23:00 |只看作者 |坛友微信交流群
/*EqWBin..........................*/
%macro eqwbinn (dsin,xvar,nb,xbvar,dsout,dsmap);
/*extract max and min values */
proc sql noprint;
select max(&xvar) into :vmax from &dsin;
select min(&xvar) into :vmin from &dsin;
run;quit;
/*calculate the bin size*/
%let bs =%sysevalf((&vmax-&vmin)/&nb);
/*loop on each of the values,create the bin boundaries,and count the
number of values in each bin*/
data &dsout;
set &dsin;
%do i=1 %to &nb;
%let
bin_u=%sysevalf(&vmin+&i*&bs);
%let bin_l=%sysevalf(&bin_u-&bs);
%if &i=1 %then %do;
%if &xvar>=&bin_l and &xvar<=&bin_u %then &xbvar=&i;
%end;
%else %if &i>1 %then %do;
if &xvar>&bin_l and &xvar<=&bin_u then &xbvar=&i;
%end;
%end;
run;
/* create the binning map and store the bin boundaries*/
proc sql noprint;
create table &dsmap (binmin num,binmax num,binno num);
%do i=1 %to &nb;
%let
bin_u=%sysevalf(&vmin+&i*&bs);
%let
bin_l=%sysevalf(&bin_u-&bs);
insert into &dsmap
values(&bin_l,&bin_u,&i);
%end;
quit;
%mend;

使用道具

地板
neoliberals 发表于 2019-6-25 19:23:16 |只看作者 |坛友微信交流群
/*EqWBin..........................*/
%macro eqwbinn (dsin,xvar,nb,xbvar,dsout,dsmap);
/*extract max and min values */
proc sql noprint;
select max(&xvar) into :vmax from &dsin;
select min(&xvar) into :vmin from &dsin;
run;quit;
/*calculate the bin size*/
%let bs =%sysevalf((&vmax-&vmin)/&nb);
/*loop on each of the values,create the bin boundaries,and count the
number of values in each bin*/
data &dsout;
set &dsin;
%do i=1 %to &nb;
%let
bin_u=%sysevalf(&vmin+&i*&bs);
%let bin_l=%sysevalf(&bin_u-&bs);
%if &i=1 %then %do;
%if &xvar>=&bin_l and &xvar<=&bin_u %then &xbvar=&i;
%end;
%else %if &i>1 %then %do;
if &xvar>&bin_l and &xvar<=&bin_u then &xbvar=&i;
%end;
%end;
run;
/* create the binning map and store the bin boundaries*/
proc sql noprint;
create table &dsmap (binmin num,binmax num,binno num);
%do i=1 %to &nb;
%let
bin_u=%sysevalf(&vmin+&i*&bs);
%let
bin_l=%sysevalf(&bin_u-&bs);
insert into &dsmap
values(&bin_l,&bin_u,&i);
%end;
quit;
%mend;

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-27 12:17