<?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 Re: Need a macro to apply syntax to range of years and variety of states in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-a-macro-to-apply-syntax-to-range-of-years-and-variety-of/m-p/165090#M31899</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry I haven't been more prompt in replying -- we had another project come up that took precedence.&amp;nbsp; And now w/ the holiday break coming up, I probably won't get back to this till January.&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote" modifiedtitle="true"&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;snoopy369 wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Is your syntax the same for each state/year/etc.?&amp;nbsp; So you've got something like&lt;/P&gt;
&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;/P&gt;
&lt;P&gt;proc means data=TX_DATA_2005;&lt;/P&gt;
&lt;P&gt;var OUTCOME1 OUTCOME2;&lt;/P&gt;
&lt;P&gt;outout out=TX_OUTPUT_2005 mean=;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;/P&gt;
&lt;P&gt;and you want to alter "TX" and "2005" ?&lt;/P&gt;
&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;/P&gt;
&lt;P&gt;You may be able to do this without a macro, depending on your analysis.&amp;nbsp; Many analyses can be done with BY or CLASS to handle the the states.&lt;/P&gt;
&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;/P&gt;
&lt;P&gt;For example, if you have one dataset MYDATA, and it has STATE and YEAR as variable:&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;Yeah that's the basic idea (though the syntax is a lot more complicated).&amp;nbsp; The problem with starting from the original source file that has all 50 states is that the files are massive (about 320GB).&amp;nbsp; It takes about 3hrs just to extract the data for 1 state for 1 year.&amp;nbsp; That's why I have separate files for each state/year combination.&amp;nbsp; I could take just the 6 states of interest and combine them into a smaller source file, but I still think that would result in much slower processing times.&amp;nbsp; Besides, the states of interest will change depending on the disease we're investigating.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;
&lt;P&gt;Also, I'm actually unsure what you're question is.&amp;nbsp; You've stated the need for a macro, so are you:&lt;/P&gt;
&lt;P&gt;1. Looking to hire a programmer to convert code to macro&lt;/P&gt;
&lt;P&gt;2. Looking for references&lt;/P&gt;
&lt;P&gt;3. Looking for instructions&lt;/P&gt;
&lt;P&gt;4. Looking for a helpful person to read your mind and magically understand your data structure, code and create a macro and post it here &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;5. Looking for how to convert your current code (you would need to post it) to a macro. Though I highly suggest reading above paper and trying yourself first.&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;Well #4 would be great, actually :smileysilly:&amp;nbsp; But a combination of 2, 3, and maybe a bit of 4 is more realistic!&amp;nbsp; I took a seminar on SAS macros, but it was several years ago and I never actually wrote any macros.&amp;nbsp; So I have very limited knowledge on the subject.&amp;nbsp; The paper u posted looks like it will be helpful, so maybe the best thing to do at this point is try to write as much of the macro as I can based on the paper and what snoopy369 posted, and then bring that back here for advice on how to tweak it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;Regardless of who does the coding, make sure that the macro works for Oregon and Nebraska.&amp;nbsp; Their abbreviations (OR and NE) are also significant words in macro language and, depending on how they are used in the macro, can require special handling.&lt;/PRE&gt;&lt;P&gt;Good to know.&amp;nbsp; I'm not sure we'll be using those states at any point, but I'll keep it in mind!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 Dec 2013 15:55:19 GMT</pubDate>
    <dc:creator>Wolverine</dc:creator>
    <dc:date>2013-12-19T15:55:19Z</dc:date>
    <item>
      <title>Need a macro to apply syntax to range of years and variety of states</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-a-macro-to-apply-syntax-to-range-of-years-and-variety-of/m-p/165086#M31895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We're testing all sorts of healthcare quality measures.&amp;nbsp; Our data currently includes data on all 50 states from 2005-2009.&amp;nbsp; Eventually we'll get 2010 and possibly 2011 as well.&amp;nbsp; Each state and each year have their own separate files.&amp;nbsp; Currently I'm running syntax on FL, IL, LA, MI, SC, and TX.&amp;nbsp; Our next round will include CA and CO as well.&amp;nbsp; My process up to this point has to be write the syntax I need for TX for 2005.&amp;nbsp; Then I do a find and replace to create another version for 2006.&amp;nbsp; The measures are restricted to kids of certain ages, so I manually have to change the birthdates for each year as well.&amp;nbsp; After all the years are done for TX, I do a find and replace to change the state. This process is repeated until all the states and all the years are covered.&amp;nbsp; The filename and folder structure are consistent so that only the state and year vary across files and folders.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So what I'd like is a macro that would allow me to input a list of states, a range of years, and the required birthdates for 2005.&amp;nbsp; Then the macro would take the appropriate syntax I've written for the measure, and automatically apply it for each state and each year (including corrected birthdates).&amp;nbsp; The macro would also adjust the titles for the output tables with the correct year and state.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also forgot to mention that some of the measures require a 2-year enrollment period to be sure that the kid had Medicaid coverage in the year prior to the measurement year.&amp;nbsp; In other words, we have to combine data from 2005 and 2006 to do a measurement on 2006.&amp;nbsp; And in this situation, we can't test 2005 as the measurement year.&amp;nbsp; And even though we using the 2005 data, the birthdates would be for 2006 because that is the measurement year.&amp;nbsp; But other measures just use a 1 year enrollment period, so we only need data from the measurement year itself.&amp;nbsp; So ideally, the macro could ask what the enrollment period is and adjust the years accordingly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Dec 2013 19:06:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-a-macro-to-apply-syntax-to-range-of-years-and-variety-of/m-p/165086#M31895</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2013-12-05T19:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: Need a macro to apply syntax to range of years and variety of states</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-a-macro-to-apply-syntax-to-range-of-years-and-variety-of/m-p/165087#M31896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is your syntax the same for each state/year/etc.?&amp;nbsp; So you've got something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc means data=TX_DATA_2005;&lt;/P&gt;&lt;P&gt;var OUTCOME1 OUTCOME2;&lt;/P&gt;&lt;P&gt;outout out=TX_OUTPUT_2005 mean=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and you want to alter "TX" and "2005" ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may be able to do this without a macro, depending on your analysis.&amp;nbsp; Many analyses can be done with BY or CLASS to handle the the states.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, if you have one dataset MYDATA, and it has STATE and YEAR as variable:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc means data=MYDATA;&lt;/P&gt;&lt;P&gt;class state year;&lt;/P&gt;&lt;P&gt;types state*year;&lt;/P&gt;&lt;P&gt;var OUTCOME1 OUTCOME2;&lt;/P&gt;&lt;P&gt;output out=MYDATAOUT mean=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That would work much more easily than a macro, and BY STATE YEAR; would work as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If that doesn't work for some reason (and I strongly encourage trying that first, it's much more maintainable), this is roughly how you'd do things:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro myAnalysis(State=,year=);&lt;/P&gt;&lt;P&gt;proc means data=&amp;amp;state._DATA_&amp;amp;year.;&lt;/P&gt;&lt;P&gt;var OUTCOME1 OUTCOME2;&lt;/P&gt;&lt;P&gt;outout out=&amp;amp;state._OUTPUT_&amp;amp;year. mean=;&lt;/P&gt;&lt;P&gt;title "Analysis of &amp;amp;state for &amp;amp;year.";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend myAnalysis;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select distinct cats('%myAnalysis(state=',state,',year=',year,')') into :runlist separated by ' '&lt;/P&gt;&lt;P&gt; from styrdataset;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;runlist.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That assumes that STYRDATASET has the various possible state/years in it in some fashion (this might be a source dataset, or an artificially created one, or even an excel file you import that someone who wants an analysis run for a state/year set fills out).&amp;nbsp; &amp;amp;runlist. calls the macro %myAnalysis.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Dec 2013 19:43:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-a-macro-to-apply-syntax-to-range-of-years-and-variety-of/m-p/165087#M31896</guid>
      <dc:creator>snoopy369</dc:creator>
      <dc:date>2013-12-05T19:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need a macro to apply syntax to range of years and variety of states</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-a-macro-to-apply-syntax-to-range-of-years-and-variety-of/m-p/165088#M31897</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://www.ats.ucla.edu/stat/sas/library/nesug99/bt066.pdf" title="http://www.ats.ucla.edu/stat/sas/library/nesug99/bt066.pdf"&gt;http://www.ats.ucla.edu/stat/sas/library/nesug99/bt066.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This isn't a hard job if you have the code written already, just need to learn where to define the parameters.&lt;/P&gt;&lt;P&gt;The paper above will get you started and finished probably.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, I'm actually unsure what you're question is.&amp;nbsp; You've stated the need for a macro, so are you:&lt;/P&gt;&lt;P&gt;1. Looking to hire a programmer to convert code to macro&lt;/P&gt;&lt;P&gt;2. Looking for references&lt;/P&gt;&lt;P&gt;3. Looking for instructions&lt;/P&gt;&lt;P&gt;4. Looking for a helpful person to read your mind and magically understand your data structure, code and create a macro and post it here &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;5. Looking for how to convert your current code (you would need to post it) to a macro. Though I highly suggest reading above paper and trying yourself first.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Dec 2013 19:51:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-a-macro-to-apply-syntax-to-range-of-years-and-variety-of/m-p/165088#M31897</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-12-05T19:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: Need a macro to apply syntax to range of years and variety of states</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-a-macro-to-apply-syntax-to-range-of-years-and-variety-of/m-p/165089#M31898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Regardless of who does the coding, make sure that the macro works for Oregon and Nebraska.&amp;nbsp; Their abbreviations (OR and NE) are also significant words in macro language and, depending on how they are used in the macro, can require special handling.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Dec 2013 19:54:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-a-macro-to-apply-syntax-to-range-of-years-and-variety-of/m-p/165089#M31898</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-12-05T19:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need a macro to apply syntax to range of years and variety of states</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-a-macro-to-apply-syntax-to-range-of-years-and-variety-of/m-p/165090#M31899</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry I haven't been more prompt in replying -- we had another project come up that took precedence.&amp;nbsp; And now w/ the holiday break coming up, I probably won't get back to this till January.&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote" modifiedtitle="true"&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;snoopy369 wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Is your syntax the same for each state/year/etc.?&amp;nbsp; So you've got something like&lt;/P&gt;
&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;/P&gt;
&lt;P&gt;proc means data=TX_DATA_2005;&lt;/P&gt;
&lt;P&gt;var OUTCOME1 OUTCOME2;&lt;/P&gt;
&lt;P&gt;outout out=TX_OUTPUT_2005 mean=;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;/P&gt;
&lt;P&gt;and you want to alter "TX" and "2005" ?&lt;/P&gt;
&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;/P&gt;
&lt;P&gt;You may be able to do this without a macro, depending on your analysis.&amp;nbsp; Many analyses can be done with BY or CLASS to handle the the states.&lt;/P&gt;
&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;/P&gt;
&lt;P&gt;For example, if you have one dataset MYDATA, and it has STATE and YEAR as variable:&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;Yeah that's the basic idea (though the syntax is a lot more complicated).&amp;nbsp; The problem with starting from the original source file that has all 50 states is that the files are massive (about 320GB).&amp;nbsp; It takes about 3hrs just to extract the data for 1 state for 1 year.&amp;nbsp; That's why I have separate files for each state/year combination.&amp;nbsp; I could take just the 6 states of interest and combine them into a smaller source file, but I still think that would result in much slower processing times.&amp;nbsp; Besides, the states of interest will change depending on the disease we're investigating.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;
&lt;P&gt;Also, I'm actually unsure what you're question is.&amp;nbsp; You've stated the need for a macro, so are you:&lt;/P&gt;
&lt;P&gt;1. Looking to hire a programmer to convert code to macro&lt;/P&gt;
&lt;P&gt;2. Looking for references&lt;/P&gt;
&lt;P&gt;3. Looking for instructions&lt;/P&gt;
&lt;P&gt;4. Looking for a helpful person to read your mind and magically understand your data structure, code and create a macro and post it here &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;5. Looking for how to convert your current code (you would need to post it) to a macro. Though I highly suggest reading above paper and trying yourself first.&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;Well #4 would be great, actually :smileysilly:&amp;nbsp; But a combination of 2, 3, and maybe a bit of 4 is more realistic!&amp;nbsp; I took a seminar on SAS macros, but it was several years ago and I never actually wrote any macros.&amp;nbsp; So I have very limited knowledge on the subject.&amp;nbsp; The paper u posted looks like it will be helpful, so maybe the best thing to do at this point is try to write as much of the macro as I can based on the paper and what snoopy369 posted, and then bring that back here for advice on how to tweak it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;Regardless of who does the coding, make sure that the macro works for Oregon and Nebraska.&amp;nbsp; Their abbreviations (OR and NE) are also significant words in macro language and, depending on how they are used in the macro, can require special handling.&lt;/PRE&gt;&lt;P&gt;Good to know.&amp;nbsp; I'm not sure we'll be using those states at any point, but I'll keep it in mind!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Dec 2013 15:55:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-a-macro-to-apply-syntax-to-range-of-years-and-variety-of/m-p/165090#M31899</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2013-12-19T15:55:19Z</dc:date>
    </item>
  </channel>
</rss>

