<?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: PROC REPORT macro for define and column statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-macro-for-define-and-column-statement/m-p/520465#M141135</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=merged split='|';
    column bsoc sort term ('Dose Level (T cells/kg)' 
        %do i=1 %to &amp;amp;n; str&amp;amp;&amp;amp;coh&amp;amp;i %end; strall);
    define bsoc /order noprint;
    define sort / order noprint;
    define term /display left style(column)={width=1in} 'System Organ
        Class|Preferred Term';
    %do i=1 %to &amp;amp;n;
        define str&amp;amp;&amp;amp;coh&amp;amp;i /display right style(column)={width=.9in} 
            "Cohort &amp;amp;&amp;amp;coh&amp;amp;i|(N=&amp;amp;&amp;amp;chtsize&amp;amp;i)|n (%)";
    %end;
    define strall /display right style(column)={width=.9in} 
        "Total|(N=&amp;amp;COHORTCTtotal.)"; 
    compute term;
        if sort ne 1 then do;
            call define(_col_,"style","style=[indent=50]"); 
        end; 
    endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You have to call this inside a macro, as the %DO command is not valid in open code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Dec 2018 18:01:42 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-12-11T18:01:42Z</dc:date>
    <item>
      <title>PROC REPORT macro for define and column statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-macro-for-define-and-column-statement/m-p/520455#M141128</link>
      <description>&lt;P&gt;I have this sql&amp;nbsp;code that puts out the cohorts depending on its variability per different studies.&amp;nbsp; I want to use it in proc define to automatically define the columns based on the number of cohorts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql ;&lt;BR /&gt; select count(distinct cohort)&lt;BR /&gt; into :n&lt;BR /&gt; from adae;&lt;BR /&gt; &lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;select distinct cohort&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt; into :coh1 - :coh%left(&amp;amp;n)&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt; from adae;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt; select count (distinct subject)&lt;BR /&gt; into :chtsize1 - :chtsize%left(&amp;amp;n)&lt;BR /&gt; from adae&lt;BR /&gt; group by cohort;&lt;BR /&gt; select count (distinct subject)&lt;BR /&gt; into :COHORTCTtotal&lt;BR /&gt; from adae;&lt;BR /&gt; select distinct "'"||STRIP(cohort)||"'" into:cohortlist separated by ', '&lt;BR /&gt; from adae;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you see the column statement and define statement where I have str2A, STR2B, STR1a, STR1B - these letters after strXX are the cohorts I need from&amp;nbsp;&lt;STRONG&gt;coh1 - :coh%left(&amp;amp;n) macro in the above sql step. How do I get this in the column and define statement without having to manually type cohort names since the names and number of cohorts vary per study.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc report data=merged split='|';&lt;BR /&gt; column bsoc sort term ('Dose Level (T cells/kg)' &lt;STRONG&gt;&lt;FONT color="#FF00FF"&gt;str2a str2b str1a str1b&lt;/FONT&gt;&lt;/STRONG&gt; strall);&lt;BR /&gt; define bsoc /order noprint;&lt;BR /&gt; define sort / order noprint;&lt;BR /&gt; define term /display left style(column)={width=1in} 'System Organ Class|Preferred Term';&lt;BR /&gt; define &lt;STRONG&gt;&lt;FONT color="#FF00FF"&gt;str2a&lt;/FONT&gt;&lt;/STRONG&gt; /display right style(column)={width=.9in} "Cohort 2A|(N=&amp;amp;chtsize3.)|n (%)";&lt;BR /&gt; define &lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;str2b&lt;/STRONG&gt;&lt;/FONT&gt; /display right style(column)={width=.9in} "Cohort 2B|(N=&amp;amp;chtsize4.)|n (%)";&lt;BR /&gt; define &lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;str1a&lt;/STRONG&gt; &lt;/FONT&gt;/display right style(column)={width=.9in} "Cohort 1A|(N=&amp;amp;chtsize1.)|n (%)"; &lt;BR /&gt; define &lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;str1b&lt;/STRONG&gt; &lt;/FONT&gt;/display right style(column)={width=.9in} "Cohort 1B|(N=&amp;amp;chtsize2.)|n (%)"; &lt;BR /&gt; define strall /display right style(column)={width=.9in} "Total|(N=&amp;amp;COHORTCTtotal.)"; &lt;BR /&gt; compute term;&lt;BR /&gt; if sort ne 1 then do;&lt;BR /&gt; call define(_col_,"style","style=[indent=50]"); &lt;BR /&gt; end; &lt;BR /&gt; endcomp;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 17:28:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-macro-for-define-and-column-statement/m-p/520455#M141128</guid>
      <dc:creator>saslove</dc:creator>
      <dc:date>2018-12-11T17:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT macro for define and column statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-macro-for-define-and-column-statement/m-p/520465#M141135</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=merged split='|';
    column bsoc sort term ('Dose Level (T cells/kg)' 
        %do i=1 %to &amp;amp;n; str&amp;amp;&amp;amp;coh&amp;amp;i %end; strall);
    define bsoc /order noprint;
    define sort / order noprint;
    define term /display left style(column)={width=1in} 'System Organ
        Class|Preferred Term';
    %do i=1 %to &amp;amp;n;
        define str&amp;amp;&amp;amp;coh&amp;amp;i /display right style(column)={width=.9in} 
            "Cohort &amp;amp;&amp;amp;coh&amp;amp;i|(N=&amp;amp;&amp;amp;chtsize&amp;amp;i)|n (%)";
    %end;
    define strall /display right style(column)={width=.9in} 
        "Total|(N=&amp;amp;COHORTCTtotal.)"; 
    compute term;
        if sort ne 1 then do;
            call define(_col_,"style","style=[indent=50]"); 
        end; 
    endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You have to call this inside a macro, as the %DO command is not valid in open code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 18:01:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-macro-for-define-and-column-statement/m-p/520465#M141135</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-12-11T18:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT macro for define and column statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-macro-for-define-and-column-statement/m-p/520486#M141143</link>
      <description>&lt;P&gt;Wow! This works perfectly!!! Exactly what I needed. Thanks a ton &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 18:42:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-macro-for-define-and-column-statement/m-p/520486#M141143</guid>
      <dc:creator>saslove</dc:creator>
      <dc:date>2018-12-11T18:42:06Z</dc:date>
    </item>
  </channel>
</rss>

