BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Geo-
Quartz | Level 8

the macro for binning of decision tree function included in sas is below:

%macro en();


data test_num;

set mywork.train(drop = survived);

run;


data num;

set sashelp.vcolumn;

where memname = 'TEST_NUM' and libname = 'WORK' and type = 'num';

run;


proc sql noprint;

select name into:numname separated by ' ' from num;

quit;

%let i = 1;

%do %until(%scan(&numname.,&i.,' ')=);

%let numnamei = %scan(&numname.,&i.,' ' );

ods graphics on;


proc hpsplit data= mywork.train intervalbins=100 leafsize=1000 maxbranch=5 MAXDEPTH=4 Missing=SIMILARITY;

target survived; 

input &numnamei./ level=int; 

output =tem1_&numnamei.

importance=temp2_&numnamei.

nodestats=temp3_&numnamei. 

prunesubtree=temp4_&numnamei.;

run;


data tu_&numnamei.;

set temp3_&numnamei.;

if DEPTH = 0 then delete;

rt_&numnamei.=input(level0,8.8);

run ;

proc sgplot data=tu_&numnamei. ;

yaxis label="fenbu" min=0 max=4000;

vbar DECISION/response=n BARWIDTH=0.5 transparency=0.5;

vline DECISION/response=rt_&numnamei. y2axis lineattrs=(color=red );

symbol color=red i=spline ;

symbol2 color=red i=spline;

label DECISION=&numnamei.'renshufenbu' n='zongliang' rt_&numnamei.='weiyuelv';

run;

%let i = %eval(&i.+1);

%end;

%mend;

%en();

1.jpg

 

May someone tell me what's wrong and how to fix it?

 

data mywork.train is like:

PassengerIdSurvivedPclassNameSexAgeSibSpParchTicketFareCabinEmbarked
103Braund, Mr. Owen Harrismale2210A/5 211717.25 S
211Cumings, Mrs. John Bradley (Florence Briggs Thayer)female3810PC 1759971.2833C85C
313Heikkinen, Miss. Lainafemale2600STON/O2. 31012827.925 S
411Futrelle, Mrs. Jacques Heath (Lily May Peel)female351011380353.1C123S
503Allen, Mr. William Henrymale35003734508.05 S
603Moran, Mr. Jamesmale 003308778.4583 Q
701McCarthy, Mr. Timothy Jmale54001746351.8625E46S
803Palsson, Master. Gosta Leonardmale23134990921.075 S
913Johnson, Mrs. Oscar W (Elisabeth Vilhelmina Berg)female270234774211.1333 S
1012Nasser, Mrs. Nicholas (Adele Achem)female141023773630.0708 C
1113Sandstrom, Miss. Marguerite Rutfemale411PP 954916.7G6S
1211Bonnell, Miss. Elizabethfemale580011378326.55C103S
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

output out=datasetname;

 

Just like in proc means, proc summary, proc reg and many other procedures.

 

you skipped the OUT part.

View solution in original post

2 REPLIES 2
ballardw
Super User

output out=datasetname;

 

Just like in proc means, proc summary, proc reg and many other procedures.

 

you skipped the OUT part.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 5671 views
  • 0 likes
  • 3 in conversation