<?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 to do a data step within a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-data-step-within-a-macro/m-p/632473#M187528</link>
    <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to define recursively a data step inside of a macro but it it nos allow. I have the code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyone can help me to transform it in something that works? Thank you all&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%do year=2017 %to 2019;&lt;/P&gt;&lt;P&gt;%do month=1 %to 12;&lt;/P&gt;&lt;P&gt;%do mod_id=8 %to 14;&lt;/P&gt;&lt;P&gt;data calibracion_&amp;amp;year.&amp;amp;month.&amp;amp;mod_id._2;&lt;BR /&gt;set test&amp;amp;year.&amp;amp;month.bmod_id&amp;amp;mod_id.;&lt;BR /&gt;format flag_event $2.;&lt;BR /&gt;flag_event = ind_incumplimiento;&lt;BR /&gt;output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;title 'Logistic Regression: M008';&lt;/P&gt;&lt;P&gt;proc logistic data=calibracion_&amp;amp;year.&amp;amp;month.&amp;amp;mod_id._2 descending; /* To model 1s rather than 0s, we use the descending option */&lt;BR /&gt;model flag_event = raw_logit / clparm=wald;&lt;BR /&gt;ods output ParameterEstimates = calibration_&amp;amp;year.&amp;amp;month.&amp;amp;mod_id.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;set calibration_&amp;amp;year.&amp;amp;month.&amp;amp;mod_id.;&lt;BR /&gt;if variable='Intercept' then call symputx('a_mod&amp;amp;year.&amp;amp;month.&amp;amp;mod_id',estimate);&lt;BR /&gt;if variable NE 'Intercept' then call symputx('b_mod&amp;amp;year.&amp;amp;month.&amp;amp;mod_id',estimate);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%end; %end;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%parametros&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 16 Mar 2020 15:58:04 GMT</pubDate>
    <dc:creator>msantosp</dc:creator>
    <dc:date>2020-03-16T15:58:04Z</dc:date>
    <item>
      <title>How to do a data step within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-data-step-within-a-macro/m-p/632473#M187528</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to define recursively a data step inside of a macro but it it nos allow. I have the code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyone can help me to transform it in something that works? Thank you all&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%do year=2017 %to 2019;&lt;/P&gt;&lt;P&gt;%do month=1 %to 12;&lt;/P&gt;&lt;P&gt;%do mod_id=8 %to 14;&lt;/P&gt;&lt;P&gt;data calibracion_&amp;amp;year.&amp;amp;month.&amp;amp;mod_id._2;&lt;BR /&gt;set test&amp;amp;year.&amp;amp;month.bmod_id&amp;amp;mod_id.;&lt;BR /&gt;format flag_event $2.;&lt;BR /&gt;flag_event = ind_incumplimiento;&lt;BR /&gt;output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;title 'Logistic Regression: M008';&lt;/P&gt;&lt;P&gt;proc logistic data=calibracion_&amp;amp;year.&amp;amp;month.&amp;amp;mod_id._2 descending; /* To model 1s rather than 0s, we use the descending option */&lt;BR /&gt;model flag_event = raw_logit / clparm=wald;&lt;BR /&gt;ods output ParameterEstimates = calibration_&amp;amp;year.&amp;amp;month.&amp;amp;mod_id.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;set calibration_&amp;amp;year.&amp;amp;month.&amp;amp;mod_id.;&lt;BR /&gt;if variable='Intercept' then call symputx('a_mod&amp;amp;year.&amp;amp;month.&amp;amp;mod_id',estimate);&lt;BR /&gt;if variable NE 'Intercept' then call symputx('b_mod&amp;amp;year.&amp;amp;month.&amp;amp;mod_id',estimate);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%end; %end;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%parametros&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Mar 2020 15:58:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-data-step-within-a-macro/m-p/632473#M187528</guid>
      <dc:creator>msantosp</dc:creator>
      <dc:date>2020-03-16T15:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a data step within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-data-step-within-a-macro/m-p/632474#M187529</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/234569"&gt;@msantosp&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to define recursively a data step inside of a macro but it it nos allow. I have the code below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyone can help me to transform it in something that works? Thank you all&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I would suggest you eliminate all of the macros and macro variables, append all of your data sets into 1 big one, and perform PROC LOGISTIC with a BY statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;by year month mod_id;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You get the same results, with a lot less programming.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Mar 2020 16:23:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-data-step-within-a-macro/m-p/632474#M187529</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-16T16:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a data step within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-data-step-within-a-macro/m-p/632478#M187530</link>
      <description>And append your output calibration data sets together to keep your estimates in a table, don't create a ton of macro variables.</description>
      <pubDate>Mon, 16 Mar 2020 16:13:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-data-step-within-a-macro/m-p/632478#M187530</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-03-16T16:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a data step within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-data-step-within-a-macro/m-p/632514#M187538</link>
      <description>&lt;P&gt;A few comments and questions.&lt;/P&gt;
&lt;P&gt;It looks like you are NOT doing any recursion.&amp;nbsp; Just simple DO loops.&amp;nbsp; (If you every need to process parts of a year then you might want to loop over month offset number instead of YEAR and MONTH.&amp;nbsp; You can then calculate the date using INTNX() function that way you could loop from sep to june for example.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why did you attach the $2 format to the variable FLAG_EVENT?&amp;nbsp; Are you trying to truncate the values that are displayed to just the first two?&amp;nbsp; If you wanted to define it as new variable then just use LENGTH statement.&amp;nbsp; If you just want to use the first two characters of &lt;SPAN&gt;ind_incumplimiento you can use SUBSTR().&amp;nbsp; Note that th&lt;/SPAN&gt;ere is no need to attach the $ format, SAS already knows how to display character variables so it does not need you to tell it to use some special FORMAT for them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why are you placing the ESTIMATE values into macro variables?&amp;nbsp; You do not seem to be using those macro variables for anything.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Mar 2020 18:18:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-data-step-within-a-macro/m-p/632514#M187538</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-16T18:18:42Z</dc:date>
    </item>
  </channel>
</rss>

