<?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: Dynamic Catx Macro for % and CIs in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Catx-Macro-for-and-CIs/m-p/509366#M136928</link>
    <description>Go back 5 steps. How did you get your data? What does the input data look like? What do you want as output?</description>
    <pubDate>Wed, 31 Oct 2018 22:14:13 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-10-31T22:14:13Z</dc:date>
    <item>
      <title>Dynamic Catx Macro for % and CIs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Catx-Macro-for-and-CIs/m-p/509217#M136863</link>
      <description>&lt;P&gt;I want to create a macro to dynamically catx&amp;nbsp;a percentage with a lower and upper CI.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The variables always look like this:&lt;/P&gt;&lt;P&gt;a_percent a_low a_high&lt;/P&gt;&lt;P&gt;b_percent b_low b_high&lt;/P&gt;&lt;P&gt;c_percent c_low c_high&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Originally I was trying to&amp;nbsp;put the suffix as a prefix so I can&amp;nbsp;create arrays for percents, lows, and highs. Then I would be able to reference the arrays in a catx macro.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;if 0 then set have;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;array percent {*} percent:;&lt;BR /&gt;array low {*} low:;&lt;BR /&gt;array high {*} high:;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;call symputx("dim_percent", dim(percent));&lt;BR /&gt;call symputx("dim_low",dim(low));&lt;BR /&gt;call symputx("dim_high", dim(high));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;do i = 1 to dim(percent);&lt;BR /&gt;call symputx(cats("percent_",i),vname(percent{i}));&lt;BR /&gt;end;&lt;BR /&gt;do i = 1 to dim(low);&lt;BR /&gt;call symputx(cats("low_",i),vname(low{i}));&lt;BR /&gt;end;&lt;BR /&gt;do i = 1 to dim(high);&lt;BR /&gt;call symputx(cats("high_",i),vname(high{i}));&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the ultimate goal is to&amp;nbsp;be able to loop&amp;nbsp;through something like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;var1=catx("^n(", put(percent(i), percent20.3), put(low(i), percent20.3));&lt;BR /&gt;varwant=catx(", ", var1, put(high(i),percent20.3))||")";&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 17:31:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Catx-Macro-for-and-CIs/m-p/509217#M136863</guid>
      <dc:creator>delgoulding</dc:creator>
      <dc:date>2018-10-31T17:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Catx Macro for % and CIs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Catx-Macro-for-and-CIs/m-p/509227#M136873</link>
      <description>Ok, so what is your question for us? &lt;BR /&gt;&lt;BR /&gt;My recommendation for something like this, is not to roll your own. Instead, reformat your data so you have a data set with:&lt;BR /&gt;&lt;BR /&gt;Value, UCLM, LCML&lt;BR /&gt;&lt;BR /&gt;Then you can use a single formula to create your values. Then if you need a different structure, reformat your data again.</description>
      <pubDate>Wed, 31 Oct 2018 17:48:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Catx-Macro-for-and-CIs/m-p/509227#M136873</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-31T17:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Catx Macro for % and CIs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Catx-Macro-for-and-CIs/m-p/509324#M136913</link>
      <description>&lt;P&gt;Clearly, you have started off on the wrong foot.&amp;nbsp; Consider this statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;array percent {*} percent: ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It appears that the intent is to take all variable names that contain "percent" somewhere in the name.&amp;nbsp; But that's not what it does.&amp;nbsp; It actually takes all variable names that begin with "percent" and it appears that you don't have any.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I agree with Reeza that you would make the problem a lot simpler by using a different structure for your data.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 20:36:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Catx-Macro-for-and-CIs/m-p/509324#M136913</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-10-31T20:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Catx Macro for % and CIs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Catx-Macro-for-and-CIs/m-p/509359#M136924</link>
      <description>&lt;P&gt;Hi! Thank you for your responses! Let me clarify my question. I am not very familiar with arrays and&amp;nbsp;have very large dataset that I am trying to put together the percentage with CIs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So my first step would be renaming my variables to having matching prefixes. However,&amp;nbsp;I am unsure how to more forward after that. I have the code below, but I can only get var1 to output once and the variable I want never outputs.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want; set have;&lt;/P&gt;&lt;P&gt;rename a_percent= percent_a;&lt;BR /&gt;rename a_low=low_a;&lt;BR /&gt;rename a_high=high_a;&lt;BR /&gt;rename b_percent= percent_b;&lt;BR /&gt;rename b_low=low_b;&lt;BR /&gt;rename b_high= high_b;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%let outcomes= a b;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want2; set want;&lt;/P&gt;&lt;P&gt;array percent {*} percent:;&lt;BR /&gt;array low {*} low:;&lt;BR /&gt;array high {*} high:;&lt;BR /&gt;array stat {*} &amp;amp;outcomes;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;do i= 1 to dim(percent);&lt;BR /&gt;do j= 1 to dim(low);&lt;/P&gt;&lt;P&gt;var1=catx("^n(", put(percent(i), percent20.3), put(low(j), comma20.3));&lt;/P&gt;&lt;P&gt;end;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;do k= 1 to dim(high);&lt;BR /&gt;do s= 1 to dim(stat);&lt;BR /&gt;stat(s)=catx(", ", var1, put(high(k), comma20.3))||")";&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance! I really appreciate any feedback/help!&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 21:45:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Catx-Macro-for-and-CIs/m-p/509359#M136924</guid>
      <dc:creator>delgoulding</dc:creator>
      <dc:date>2018-10-31T21:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Catx Macro for % and CIs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Catx-Macro-for-and-CIs/m-p/509366#M136928</link>
      <description>Go back 5 steps. How did you get your data? What does the input data look like? What do you want as output?</description>
      <pubDate>Wed, 31 Oct 2018 22:14:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Catx-Macro-for-and-CIs/m-p/509366#M136928</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-31T22:14:13Z</dc:date>
    </item>
  </channel>
</rss>

