<?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: Decimals and reference macro variables in proc report in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Decimals-and-reference-macro-variables-in-proc-report/m-p/745658#M233784</link>
    <description>Any help with referencing the macro variable in the proc report to obtain N= ?</description>
    <pubDate>Thu, 03 Jun 2021 23:04:36 GMT</pubDate>
    <dc:creator>RAVI2000</dc:creator>
    <dc:date>2021-06-03T23:04:36Z</dc:date>
    <item>
      <title>Decimals and reference macro variables in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Decimals-and-reference-macro-variables-in-proc-report/m-p/745647#M233774</link>
      <description>&lt;P&gt;I was trying to get decimal places for mean and median. I am only able to get decimal where there are zeros. How can I get decimals for other numbers?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S_RAVI_0-1622758779466.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60007i5D0A32700C4DE6CF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="S_RAVI_0-1622758779466.png" alt="S_RAVI_0-1622758779466.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc format;
value misszero
0 = '0.0'
other = [2.1];
run;

proc report data = fin nowindows missing headline headskip center split = "|" ps = 47 ls = 133 spanrows
		style(report) = [cellwidth = 100% asis = on cellspacing = 0 cellpadding = 1.0pt borderwidth = 0.6  just = center protectspecialchars=off borderbottomcolor = black ] 
		style(header) = [asis = on just = center protectspecialchars=off font_weight = bold background = white fontsize=12pt ]
		style(column) = [asis = on just = center protectspecialchars=off vjust = bottom fontsize=12pt ];
		
		columns ("Assessment Time" segment_code) ("Dose Level" armcode,(N mean median));
		
		define segment_code/"" group descending format = segmentcode.
				style(column) = [just = left cellwidth = 15% font_weight = bold] style(header) = [just=left] flow id;
		
		define armcode/"" across format = armcode.
				style(column) = [just = center cellwidth = 0.12in] ;
		
		define N/analysis sum format = 2.0
				style(column) = [just = center cellwidth = 0.4in]; 
		
		define mean/analysis sum format = misszero.
				style(column) = [just = center cellwidth = 0.4in] ;
		
		define median/analysis sum format = misszero.
				style(column) = [just = center cellwidth = 0.4in] ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also same output report, I want to reference the &amp;amp;n1, &amp;amp;n2 in the proc report code. I have created the macro variable but not able to use them in my proc report code. Not sure how I can use them.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 504px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60009i97BC1E93523957DA/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 22:33:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Decimals-and-reference-macro-variables-in-proc-report/m-p/745647#M233774</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2021-06-03T22:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: Decimals and reference macro variables in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Decimals-and-reference-macro-variables-in-proc-report/m-p/745650#M233776</link>
      <description>&lt;P&gt;You need to go back to the step where you converted them to character values and do it there.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you specify the format as 8.2 it will display with 2 decimal places. Obviously you cannot apply a numeric format to a character variable though.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;mean_char = put(mean, 8.2);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/294544"&gt;@RAVI2000&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I was trying to get decimal places for mean and median. I am only able to get decimal where there are zeros. How can I get decimals for other numbers?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S_RAVI_0-1622758779466.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60007i5D0A32700C4DE6CF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="S_RAVI_0-1622758779466.png" alt="S_RAVI_0-1622758779466.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc format;
value misszero
0 = '0.0'
other = [2.1];
run;

proc report data = fin nowindows missing headline headskip center split = "|" ps = 47 ls = 133 spanrows
		style(report) = [cellwidth = 100% asis = on cellspacing = 0 cellpadding = 1.0pt borderwidth = 0.6  just = center protectspecialchars=off borderbottomcolor = black ] 
		style(header) = [asis = on just = center protectspecialchars=off font_weight = bold background = white fontsize=12pt ]
		style(column) = [asis = on just = center protectspecialchars=off vjust = bottom fontsize=12pt ];
		
		columns ("Assessment Time" segment_code) ("Dose Level" armcode,(N mean median));
		
		define segment_code/"" group descending format = segmentcode.
				style(column) = [just = left cellwidth = 15% font_weight = bold] style(header) = [just=left] flow id;
		
		define armcode/"" across format = armcode.
				style(column) = [just = center cellwidth = 0.12in] ;
		
		define N/analysis sum format = 2.0
				style(column) = [just = center cellwidth = 0.4in]; 
		
		define mean/analysis sum format = misszero.
				style(column) = [just = center cellwidth = 0.4in] ;
		
		define median/analysis sum format = misszero.
				style(column) = [just = center cellwidth = 0.4in] ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also same output report, I want to reference the &amp;amp;n1, &amp;amp;n2 in the proc report code. I have created the macro variable but not able to use them in my proc report code. Not sure how I can use them.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 504px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60009i97BC1E93523957DA/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 22:40:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Decimals-and-reference-macro-variables-in-proc-report/m-p/745650#M233776</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-06-03T22:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: Decimals and reference macro variables in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Decimals-and-reference-macro-variables-in-proc-report/m-p/745651#M233777</link>
      <description>&lt;P&gt;2.1 is too small. The Decimal counts as one of the 2 characters and if you have negative values that would want a character as well. It might help to show the range of values you are actually concerned with. As a minimum [3.1] will display values with 1 decimal, up to 9.9.&amp;nbsp; If you have mean or median values greater than 10 you need still more width for the format such as 4.1. The number before the period is the total number of characters the format will display.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 22:44:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Decimals-and-reference-macro-variables-in-proc-report/m-p/745651#M233777</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-06-03T22:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: Decimals and reference macro variables in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Decimals-and-reference-macro-variables-in-proc-report/m-p/745652#M233778</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc format;
value misszero
0 = '0.00'
other = [8.2];
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What would you want to do with missing values? If you've taken care of that in a previous step it's fine to ignore it though.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 22:47:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Decimals-and-reference-macro-variables-in-proc-report/m-p/745652#M233778</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-06-03T22:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: Decimals and reference macro variables in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Decimals-and-reference-macro-variables-in-proc-report/m-p/745657#M233783</link>
      <description>I have assigned (updated) them as  '-'  in my proc format.</description>
      <pubDate>Thu, 03 Jun 2021 23:03:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Decimals-and-reference-macro-variables-in-proc-report/m-p/745657#M233783</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2021-06-03T23:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: Decimals and reference macro variables in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Decimals-and-reference-macro-variables-in-proc-report/m-p/745658#M233784</link>
      <description>Any help with referencing the macro variable in the proc report to obtain N= ?</description>
      <pubDate>Thu, 03 Jun 2021 23:04:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Decimals-and-reference-macro-variables-in-proc-report/m-p/745658#M233784</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2021-06-03T23:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: Decimals and reference macro variables in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Decimals-and-reference-macro-variables-in-proc-report/m-p/745660#M233786</link>
      <description>Create macro variables and add that data to your ARMCODE variable. &lt;BR /&gt;&lt;BR /&gt;Because you're using ACROSS option within PROC REPORT you cannot use use a label option. You might be able to do it via COMPUTE but it becomes harder to control your output and there's some reliance on order which can cause unexpected issues if you add another column or order changes. This needs to happen before the PROC REPORT step.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 03 Jun 2021 23:11:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Decimals-and-reference-macro-variables-in-proc-report/m-p/745660#M233786</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-06-03T23:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: Decimals and reference macro variables in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Decimals-and-reference-macro-variables-in-proc-report/m-p/745661#M233787</link>
      <description>You'll find these references helpful though older. For what you're doing, not much has changed.&lt;BR /&gt;&lt;BR /&gt;Paper&lt;BR /&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings/pdfs/sgf2008/173-2008.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings/pdfs/sgf2008/173-2008.pdf&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Code that goes along with papers&lt;BR /&gt;&lt;A href="https://support.sas.com/rnd/papers/sgf2008/complex_reports.zip" target="_blank"&gt;https://support.sas.com/rnd/papers/sgf2008/complex_reports.zip&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 03 Jun 2021 23:15:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Decimals-and-reference-macro-variables-in-proc-report/m-p/745661#M233787</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-06-03T23:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: Decimals and reference macro variables in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Decimals-and-reference-macro-variables-in-proc-report/m-p/745848#M233892</link>
      <description>&lt;P&gt;As said I have created the macro variables &amp;amp;n1, &amp;amp;n2, &amp;amp;n3.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you explain how can I add them to my armcode variable?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Counting and referencing Distinct subjects for arms;

proc sql;
	select max(0, count(distinct usubjid)) into :n1 trimmed
		from test
			where armcode = 1;
			
	select max(0, count(distinct usubjid)) into :n2 trimmed
		from test
			where armcode = 2;
			
	select max(0, count(distinct usubjid)) into :n3 trimmed
		from test
			where armcode = 3;
quit;

%put &amp;amp;n1 &amp;amp;n2 &amp;amp;n3;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;They resolve to 3, 0, 0.&lt;/P&gt;
&lt;P&gt;Now before the proc report how do I add them to the armcode variable?&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jun 2021 16:33:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Decimals-and-reference-macro-variables-in-proc-report/m-p/745848#M233892</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2021-06-04T16:33:06Z</dc:date>
    </item>
  </channel>
</rss>

