<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How do i output in a macro a unique output file/dataset for each cycle? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-output-in-a-macro-a-unique-output-file-dataset-for-each/m-p/299057#M312220</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do i output in a macro a unique output file/dataset for each cycle, to the temporary work folder, so that it will be available for use in a second macro?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro speed(univariatecate, factor);
	proc logistic data=work.sd;
		class gender &amp;amp;univariatecate. (ref="0")/param=ref;
		model Outcome(event='1')=Age_yr_ 
			gender &amp;amp;univariatecate. &amp;amp;factor./selection=none;
		output out=sdcrossvalidm2 predprobs=crossvalidate;
	run;

%mend;

%speed(bleed, PR);
%speed(bleed, ALT);
%speed(bleed, AST);

%macro speedcv(univariatecate, factor);
	proc logistic data=work.sdcrossvalidm2 plots(only label)=all;
		class gender &amp;amp;univariatecate. (ref="0")/param=ref;
		model Outcome(event='1')=Age_yr_ 
			gender &amp;amp;univariatecate. &amp;amp;factor./selection=none;
		roc pred=xp_1;
		roccontrast;
		ods output rocassociation=SDcrossvalidatedm2;
	run;

%mend;

%speed(bleed, PR);
%speed(bleed, ALT);
%speed(bleed, AST);
ods graphics off;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the code above (which don't work), the first macro&amp;nbsp;do not output unique files for each cycle {(bleed,PR),&amp;nbsp;(bleed,ALT),&amp;nbsp;(bleed,AST)}. I want to make unique files so that it will be available to the second macro which crossvalidates the first.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Help &amp;amp; guidance most appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Saiful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 17 Sep 2016 00:12:10 GMT</pubDate>
    <dc:creator>Dcicantab5</dc:creator>
    <dc:date>2016-09-17T00:12:10Z</dc:date>
    <item>
      <title>How do i output in a macro a unique output file/dataset for each cycle?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-output-in-a-macro-a-unique-output-file-dataset-for-each/m-p/299057#M312220</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do i output in a macro a unique output file/dataset for each cycle, to the temporary work folder, so that it will be available for use in a second macro?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro speed(univariatecate, factor);
	proc logistic data=work.sd;
		class gender &amp;amp;univariatecate. (ref="0")/param=ref;
		model Outcome(event='1')=Age_yr_ 
			gender &amp;amp;univariatecate. &amp;amp;factor./selection=none;
		output out=sdcrossvalidm2 predprobs=crossvalidate;
	run;

%mend;

%speed(bleed, PR);
%speed(bleed, ALT);
%speed(bleed, AST);

%macro speedcv(univariatecate, factor);
	proc logistic data=work.sdcrossvalidm2 plots(only label)=all;
		class gender &amp;amp;univariatecate. (ref="0")/param=ref;
		model Outcome(event='1')=Age_yr_ 
			gender &amp;amp;univariatecate. &amp;amp;factor./selection=none;
		roc pred=xp_1;
		roccontrast;
		ods output rocassociation=SDcrossvalidatedm2;
	run;

%mend;

%speed(bleed, PR);
%speed(bleed, ALT);
%speed(bleed, AST);
ods graphics off;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the code above (which don't work), the first macro&amp;nbsp;do not output unique files for each cycle {(bleed,PR),&amp;nbsp;(bleed,ALT),&amp;nbsp;(bleed,AST)}. I want to make unique files so that it will be available to the second macro which crossvalidates the first.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Help &amp;amp; guidance most appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Saiful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Sep 2016 00:12:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-output-in-a-macro-a-unique-output-file-dataset-for-each/m-p/299057#M312220</guid>
      <dc:creator>Dcicantab5</dc:creator>
      <dc:date>2016-09-17T00:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do i output in a macro a unique output file/dataset for each cycle?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-output-in-a-macro-a-unique-output-file-dataset-for-each/m-p/299059#M312221</link>
      <description>&lt;P&gt;Give your output files unique names....come up with some sort of naming convention that you can use in your second macro.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OR transpose your data so that PR/ALT/AST are by groups and then use BY group processing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-run-multiple-regressions/ta-p/223663" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-run-multiple-regressions/ta-p/223663&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Sep 2016 00:48:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-output-in-a-macro-a-unique-output-file-dataset-for-each/m-p/299059#M312221</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-17T00:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do i output in a macro a unique output file/dataset for each cycle?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-output-in-a-macro-a-unique-output-file-dataset-for-each/m-p/299072#M312222</link>
      <description>&lt;P&gt;As for the suggestion to create unique table names, code as below used at the begining of your first macro could do the job.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  %global my_dsname;
  %let my_dsname=t_%sysfunc(datetime(),b8601dt15.0);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then in your 2nd macro once you're done with the data set and to keep WORK tidy, you could delete the ds using code as below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets lib=%scan(work.&amp;amp;my_dsname,-2,.) nolist nowarn;
  delete %scan(&amp;amp;my_dsname,-1,.);
run;quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Sep 2016 02:42:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-output-in-a-macro-a-unique-output-file-dataset-for-each/m-p/299072#M312222</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-09-17T02:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do i output in a macro a unique output file/dataset for each cycle?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-output-in-a-macro-a-unique-output-file-dataset-for-each/m-p/299079#M312223</link>
      <description>&lt;P&gt;Thanks guys, both advices got me thinking, hence the following worked!:&lt;/P&gt;&lt;PRE&gt;%macro speed(univariatecate, factor, my_dsname);
	proc logistic data=work.sd;
		class gender &amp;amp;univariatecate. (ref="0")/param=ref;
		model Outcome(event='1')=Age_yr_ 
			gender &amp;amp;univariatecate. &amp;amp;factor./selection=none;
		output out=&amp;amp;my_dsname. predprobs=crossvalidate;
	run;

%mend;

%speed(bleed, PR, bleedpr);
%speed(bleed, ALT, bleedalt);
%speed(bleed, AST, bleedast);


%macro speedcv(univariatecate, factor, my_dsname);
	proc logistic data=&amp;amp;my_dsname. plots(only label)=all;
		class gender &amp;amp;univariatecate. (ref="0")/param=ref;
		model Outcome(event='1')=Age_yr_ 
			gender &amp;amp;univariatecate. &amp;amp;factor./selection=none;
		roc pred=xp_1;
		roccontrast;
	run;

%mend;

%speedcv(bleed, PR, bleedpr);
%speedcv(bleed, ALT, bleedalt);
%speedcv(bleed, AST, bleedast);&lt;/PRE&gt;</description>
      <pubDate>Sat, 17 Sep 2016 04:47:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-output-in-a-macro-a-unique-output-file-dataset-for-each/m-p/299079#M312223</guid>
      <dc:creator>Dcicantab5</dc:creator>
      <dc:date>2016-09-17T04:47:57Z</dc:date>
    </item>
  </channel>
</rss>

