K-FOLD CV & bootstrap

Accepted Solution Solved
Reply
Contributor
Posts: 27
Accepted Solution

K-FOLD CV & bootstrap

Hi all,

 

I have the following SAS code and I want to clear datasets from previous runs of 10-forld CV and bootstrap.  I was wondering if you would be able to advise how to do it. 

Also could you please advise how to add more resources in SAS? my SAS  do not work when when the number of replicates get to 200. 

 

Many thanks,

data kyphosis;
input y1 y2 d;
cards;
111	81	0
3	240	0
115	109	0
130	51	0
64	437	0
758	917	1
249	82	1
43	294	0
1493	101	1
5684	487	1
90	760	0
1499	147	1
229	254	0
474	305	1
88	4	0
3038	568	0
61	822	0
2134	1160	1
736	100	1
1195	136	1
5711	1037	1
10	111	0
271	271	0
1017	868	0
20	106	0
;
run;


%macro bootstrap (bootnum); *bootnum=12;

 *******************************************************************************
BOOTSTRAPPING
*******************************************************************************;

%do i = 1 %to &bootnum;

*supress log output if bootstrap samples become too large;
%if &bootnum > 10 %then %do;
	options nonotes nosource nosource2 errors=0;
%end;

*******************************************************************************
*clear datasets from previous runs;
*******************************************************************************;

   proc datasets library = work nodetails nolist;
    delete training&x.;
  run;
 
  proc datasets library = work nodetails nolist;
    delete temp&x.;
  run;


proc surveyselect data=kyphosis NOPRINT seed=1234
     out=kyphosis1a(rename=(Replicate=bootsample))
     method=urs              
     samprate=100  
     outhits            
     reps=&bootnum;       
run;

*******************************************************************************
K-FOLD CROSS VALIDATION
*******************************************************************************;

 data kyphosis1a;
    set kyphosis1a;
* if bootsample = &i;
      theRandom = ranuni(0);
   run;

proc rank data = kyphosis1a out=kRanked groups=10;
*by bootsample;
	var theRandom;
run;

%do x = 0 %to 9;
******************************************************************************
Create Training Data and Append in Libname out
*******************************************************************************;
dm log 'clear';

data training&x;
set kRanked;
where theRandom ne &x;
*by bootsample;
run;

******************************************************************************
Generate Binary variable beta1 for Biomarker 1 and Append in Libname out 1
*******************************************************************************;

proc sql;
create table temp&x as
select 
    a.y1 as compare_y1,
    b.*,
    a.y1 < b.y1 as beta
from training&x as a, training&x as b;
*order by compare_y1, y1;
quit;


%end; *end bootstrapping loop;

%end; *end 10-FOLD CROSS VALIDATIONloop;

%mend;
%bootstrap(10);


Accepted Solutions
Solution
2 weeks ago
Contributor
Posts: 27

Re: K-FOLD CV & bootstrap

Many thanks Reeza for your inputs. mY sas code work very well now. I did change the library name when I was sending my outputs

View solution in original post


All Replies
Super User
Posts: 22,591

Re: K-FOLD CV & bootstrap

I have the following SAS code and I want to clear datasets from previous runs of 10-forld CV and bootstrap.  I was wondering if you would be able to advise how to do it. 

 

 

That's what PROC DATASETS in your code does. It deletes the data sets indicated. If you want to delete more, add them to the DELETE statement. I typically like to use a naming convention, so that I can use the : colon short cut reference. 

For example if all your intermediary data sets start with CV_, you can drop all with:

 

proc datasets lib=work nodetails nolist;
delete CV_:;
run; quit;

Note that PROC DATASETS requires a QUIT statement.

 

Also could you please advise how to add more resources in SAS? my SAS  do not work when when the number of replicates get to 200. 

 

What does 'not work' mean? Are you getting an error of some kind, is it crashing or are the results not what you expect? Which step is generating the error?

 

You can add the following options before your macro to see the full log. 

options symbolgen mprint;

And if your log is getting too full, then you'll want to use PROC PRINTTO to redirect it to a file so that you don't get the annoying popups about the log being full. 

 

You can reference this paper for more details on simulating and bootstrapping efficiently in SAS:

http://www2.sas.com/proceedings/forum2007/183-2007.pdf

Solution
2 weeks ago
Contributor
Posts: 27

Re: K-FOLD CV & bootstrap

Many thanks Reeza for your inputs. mY sas code work very well now. I did change the library name when I was sending my outputs
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 92 views
  • 0 likes
  • 2 in conversation