<?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: How Index on a number in a macro when it's in the middle of the variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-Index-on-a-number-in-a-macro-when-it-s-in-the-middle-of-the/m-p/168829#M32384</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In this (an many many other) posts, it seems that "spreadsheet"-programming is deeply grounded among SAS programmers.&lt;/P&gt;&lt;P&gt;Without having tested, I'm pretty sure that a transposed data set is much easier to report on, you shouldn't even had to use a macro, no? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To anser your macro programming problem, if you want to resolve a macro variable in the middle of a text, you need to add dot as suffix, that will tell SAS that that's the end of the macro variable name.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 10 Feb 2014 11:43:14 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2014-02-10T11:43:14Z</dc:date>
    <item>
      <title>How Index on a number in a macro when it's in the middle of the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-Index-on-a-number-in-a-macro-when-it-s-in-the-middle-of-the/m-p/168827#M32382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to write a macro which does a data step on several variables. I have a set of 4 variables for 20 different trauma types (lot of variables!) I'd like to sum over each of the 15 variables. The problem is, the number which indicates which trauma group its from is in the middle of the variable&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so I have say, for each of the 20 groups:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;gt1roy&lt;/P&gt;&lt;P&gt;gt1margie&lt;/P&gt;&lt;P&gt;gt1time&lt;/P&gt;&lt;P&gt;gt1tempo&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;gt2roy&lt;/P&gt;&lt;P&gt;gt2margie&lt;/P&gt;&lt;P&gt;gt2time&lt;/P&gt;&lt;P&gt;gt2tempo&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;gt20roy&lt;/P&gt;&lt;P&gt;gt20margie&lt;/P&gt;&lt;P&gt;gt20time&lt;/P&gt;&lt;P&gt;gt20tempo&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd like to take a sum of gt1roy through gt1tempo (which has gt1=1 or 2 or 99). i'd like to sum over gt2roy through gt2tempo&amp;nbsp; (which has gt2=1 or 2 or 99), ...., and finally gt20roy through gt20tempo&amp;nbsp; (which has gt20=1 or 2 or 99). I'm interested in those cases with their gt variables = 2. And I want to do it when each group, &lt;/P&gt;&lt;P&gt;So I want somethign like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro sumz(n);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do i = 1 %to &amp;amp;n.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data new&amp;amp;i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set olddataset;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where gt&amp;amp;i=2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; traumasum&amp;amp;i = sum (of&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;gt&amp;amp;iroy &lt;/SPAN&gt;gt&amp;amp;imargie gt&amp;amp;itime gt&amp;amp;itempo);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data = new&amp;amp;i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var idnumber gt&amp;amp;iroy gt&amp;amp;imargie gt&amp;amp;itime gt&amp;amp;itempo;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%sumz(20);&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the problem is, sas doesn't recognize the index when it's in the middle of a variable. if all my variables ended with a number I could refer to variables like gtmargie&amp;amp;i gtroy&amp;amp;i etc and it would be fine. Help?Thanks!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;x&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Feb 2014 11:06:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-Index-on-a-number-in-a-macro-when-it-s-in-the-middle-of-the/m-p/168827#M32382</guid>
      <dc:creator>ginak</dc:creator>
      <dc:date>2014-02-10T11:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: How Index on a number in a macro when it's in the middle of the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-Index-on-a-number-in-a-macro-when-it-s-in-the-middle-of-the/m-p/168828#M32383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/64754/HTML/default/viewer.htm#n0700fspmubii5n1vecutttwz93n.htm"&gt;Delimiting Macro Variable Names within Text&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Feb 2014 11:40:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-Index-on-a-number-in-a-macro-when-it-s-in-the-middle-of-the/m-p/168828#M32383</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-02-10T11:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: How Index on a number in a macro when it's in the middle of the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-Index-on-a-number-in-a-macro-when-it-s-in-the-middle-of-the/m-p/168829#M32384</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In this (an many many other) posts, it seems that "spreadsheet"-programming is deeply grounded among SAS programmers.&lt;/P&gt;&lt;P&gt;Without having tested, I'm pretty sure that a transposed data set is much easier to report on, you shouldn't even had to use a macro, no? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To anser your macro programming problem, if you want to resolve a macro variable in the middle of a text, you need to add dot as suffix, that will tell SAS that that's the end of the macro variable name.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Feb 2014 11:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-Index-on-a-number-in-a-macro-when-it-s-in-the-middle-of-the/m-p/168829#M32384</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2014-02-10T11:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: How Index on a number in a macro when it's in the middle of the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-Index-on-a-number-in-a-macro-when-it-s-in-the-middle-of-the/m-p/168830#M32385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ahh thank you!! Totally forgot about the dot. Also, I'm not sure how a transposed data set would work here? Each person (one record) has a value for all of those variables (maybe I'm misunderstanding your suggestion). But thanks everyone for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Feb 2014 20:06:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-Index-on-a-number-in-a-macro-when-it-s-in-the-middle-of-the/m-p/168830#M32385</guid>
      <dc:creator>ginak</dc:creator>
      <dc:date>2014-02-11T20:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: How Index on a number in a macro when it's in the middle of the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-Index-on-a-number-in-a-macro-when-it-s-in-the-middle-of-the/m-p/168831#M32386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think Linus is indicating that it would be easier if you had multiple lines per patient, rather than your data structure of many variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you could just use BY group processing without macros &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;ie&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PT_ID, Counter, roy, margie, time, temp&lt;/P&gt;&lt;P&gt;1, 1, 0, 1, 99, 2&lt;/P&gt;&lt;P&gt;1, 2, 0, 1, 99 2&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Feb 2014 21:35:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-Index-on-a-number-in-a-macro-when-it-s-in-the-middle-of-the/m-p/168831#M32386</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-02-11T21:35:26Z</dc:date>
    </item>
  </channel>
</rss>

