<?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 : cannot get value from the last _c_ column. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-cannot-get-value-from-the-last-c-column/m-p/805454#M317294</link>
    <description>&lt;P&gt;Thank you very much Kurt_Bremser for the explanation and the solution !&lt;/P&gt;&lt;P&gt;It works perfectly for me !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a nice day &lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 01 Apr 2022 08:22:03 GMT</pubDate>
    <dc:creator>v2rt</dc:creator>
    <dc:date>2022-04-01T08:22:03Z</dc:date>
    <item>
      <title>Proc report : cannot get value from the last _c_ column.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-cannot-get-value-from-the-last-c-column/m-p/805250#M317191</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;After having searched for a long time on the internet for a similar problem I unfortunately did not find any solution or explanation to my problem. So I'm writing this post in order to try to solve it. I am using &lt;STRONG&gt;SAS 8.2 EG&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My goal is to calculate the variability (&lt;STRONG&gt;Variation&lt;/STRONG&gt;) of the number of contracts (&lt;STRONG&gt;N&lt;/STRONG&gt;) across different dates (&lt;STRONG&gt;Date_export&lt;/STRONG&gt;) for different Companies (&lt;STRONG&gt;Compagnie&lt;/STRONG&gt;). Here is a sample of my data set :&lt;/P&gt;&lt;PRE&gt;DATA Contract; 
   LENGTH Compagnie $10.;
   INPUT Compagnie $ Date_export $ ;
CARDS;
FORD 2020/01
FORD 2020/02
FORD 2020/02
FORD 2020/03
FORD 2020/03
FORD 2020/03
BMW 2020/01
BMW 2020/02
BMW 2020/02
BMW 2020/02
BMW 2020/03
BMW 2020/03
RENAULT 2020/01
RENAULT 2020/01
RENAULT 2020/01
RENAULT 2020/02
RENAULT 2020/02
RENAULT 2020/03
;
RUN;&lt;/PRE&gt;&lt;P&gt;To solve this problem I am using a PROC REPORT with a Computed value for &lt;STRONG&gt;Variation&lt;/STRONG&gt; :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;PROC REPORT DATA=Contract SPLIT='00'x style(summary)=[color=cx3e3d73 backgroundcolor=BWH] ;
COLUMN Compagnie  Date_export , (Variation N)  ;
DEFINE Compagnie / GROUP MISSING ORDER=INTERNAL style(Column)=[fontweight=bold backgroundcolor=Honeydew];
DEFINE Date_export / ACROSS ORDER=INTERNAL  '';
DEFINE N / "N";
DEFINE Variation / COMPUTED format=percent8.2 ;
compute Variation;

	_c4_ = ((_c5_ - _c3_)/(_c3_));
	_c6_ = ((_c7_ - _c5_)/(_c5_));
if _c4_ &amp;gt;0 then call define ('_c4_','style','style={color=green}'); else call define ('_c4_','style','style={color=red}');
if _c6_ &amp;gt;0 then call define ('_c6_','style','style={color=green}'); else call define ('_c6_','style','style={color=red}');
endcomp;
RBREAK  AFTER  /SUMMARIZE;
RUN;&lt;/PRE&gt;&lt;P&gt;And here is the result of this program:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="v2rt_0-1648728916751.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69989iC258B03D0A392598/image-size/medium?v=v2&amp;amp;px=400" role="button" title="v2rt_0-1648728916751.png" alt="v2rt_0-1648728916751.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As you can see, the &lt;STRONG&gt;Variation&lt;/STRONG&gt; column for the date &lt;STRONG&gt;2020/03&lt;/STRONG&gt; is not completed even though I coded it ( &lt;STRONG&gt;_c6_ = ((_c7_ - _c5_)/(_c5_));&lt;/STRONG&gt; ). After making some changes, I realized that I could not get the data from the &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;_c7_&lt;/STRONG&gt; &lt;/FONT&gt;column (the last column). Because if I do &lt;STRONG&gt;_c6_ = _c3_&lt;/STRONG&gt; for example, my column fills up as it should. So I think the problem would come from the last column &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;_c7_&lt;/STRONG&gt;&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is even more surprising is that when I switch &lt;STRONG&gt;N&lt;/STRONG&gt; and &lt;STRONG&gt;Variation&lt;/STRONG&gt; in the COLUMN line of the PROC REPORT and change the formulas of the corresponding columns, as below :&lt;/P&gt;&lt;PRE&gt;PROC REPORT DATA=Contract SPLIT='00'x style(summary)=[color=cx3e3d73 backgroundcolor=BWH] ;
&lt;FONT color="#000000"&gt;COLUMN Compagnie  Date_export , (&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;N Variation&lt;/STRONG&gt;&lt;/FONT&gt;)  ;&lt;/FONT&gt;
DEFINE Compagnie / GROUP MISSING ORDER=INTERNAL style(Column)=[fontweight=bold backgroundcolor=Honeydew];
DEFINE Date_export / ACROSS ORDER=INTERNAL  '';
DEFINE N / "N";
DEFINE Variation / COMPUTED format=percent8.2 ;
compute Variation;

	&lt;FONT color="#FF0000"&gt;_c5_ = ((_c4_ - _c2_)/(_c2_));
	_c7_ = ((_c6_ - _c4_)/(_c4_));&lt;/FONT&gt;
if &lt;FONT color="#FF0000"&gt;_c5_&lt;/FONT&gt; &amp;gt;0 then call define ('&lt;FONT color="#FF0000"&gt;_c5_&lt;/FONT&gt;','style','style={color=green}'); else call define ('&lt;FONT color="#FF0000"&gt;_c5_'&lt;/FONT&gt;,'style','style={color=red}');
if &lt;FONT color="#FF0000"&gt;_c7_&lt;/FONT&gt; &amp;gt;0 then call define ('&lt;FONT color="#FF0000"&gt;_c7_&lt;/FONT&gt;','style','style={color=green}'); else call define ('&lt;FONT color="#FF0000"&gt;_c7_&lt;/FONT&gt;','style','style={color=red}');
endcomp;
RBREAK  AFTER  /SUMMARIZE;
RUN;&lt;/PRE&gt;&lt;P&gt;I then get this result:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="v2rt_1-1648729299844.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69990iFF36669D9DA7DB93/image-size/medium?v=v2&amp;amp;px=400" role="button" title="v2rt_1-1648729299844.png" alt="v2rt_1-1648729299844.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which is the right result but it &lt;U&gt;isn't the shape of the table I want&lt;BR /&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;Indeed, it is important for me to have the &lt;STRONG&gt;Variation&lt;/STRONG&gt; before the &lt;STRONG&gt;N&lt;/STRONG&gt; for each &lt;STRONG&gt;Export_Date&lt;/STRONG&gt; as in the first example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you by advance for your help &lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 13:18:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-cannot-get-value-from-the-last-c-column/m-p/805250#M317191</guid>
      <dc:creator>v2rt</dc:creator>
      <dc:date>2022-03-31T13:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report : cannot get value from the last _c_ column.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-cannot-get-value-from-the-last-c-column/m-p/805385#M317256</link>
      <description>&lt;P&gt;It appears the last columns is not being read.&lt;BR /&gt;To test it I added one row to your dataset as shown below. I wish somebody could enlighten us.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA Contract; 
   LENGTH Compagnie $10.;
   INPUT Compagnie $ Date_export $ ;
CARDS;
FORD 2020/01
FORD 2020/02
FORD 2020/02
FORD 2020/03
FORD 2020/03
FORD 2020/03
BMW 2020/01
BMW 2020/02
BMW 2020/02
BMW 2020/02
BMW 2020/03
BMW 2020/03
RENAULT 2020/01
RENAULT 2020/01
RENAULT 2020/01
RENAULT 2020/02
RENAULT 2020/02
RENAULT 2020/03
ZZ       2020/04
;
RUN;

PROC REPORT DATA=Contract SPLIT='00'x style(summary)=[color=cx3e3d73 backgroundcolor=BWH] ;
COLUMN Compagnie  Date_export , (Variation N )  ;
DEFINE Compagnie / GROUP MISSING ORDER=INTERNAL style(Column)=[fontweight=bold backgroundcolor=Honeydew];
DEFINE Date_export / ACROSS ORDER=INTERNAL  '';
DEFINE N / " N ";
DEFINE Variation / COMPUTED format=percent12.2 ;
compute Variation;
	_C4_ = ((_C5_ - _C3_)/(_C3_));
	_C6_ =((_C7_ -_C5_)/(_C5_));
if _C4_ &amp;gt;0 then call define ('_c4_','style','style={color=green}'); else call define ('_c4_','style','style={color=red}');
if _C6_ &amp;gt;0 then call define ('_c6_','style','style={color=green}'); else call define ('_c6_','style','style={color=red}');
endcomp;
RBREAK  AFTER  /SUMMARIZE;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The out put was&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sajid01_0-1648753364972.png" style="width: 530px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70014i394CB23538541E14/image-dimensions/530x199?v=v2" width="530" height="199" role="button" title="Sajid01_0-1648753364972.png" alt="Sajid01_0-1648753364972.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 19:03:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-cannot-get-value-from-the-last-c-column/m-p/805385#M317256</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2022-03-31T19:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report : cannot get value from the last _c_ column.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-cannot-get-value-from-the-last-c-column/m-p/805447#M317290</link>
      <description>&lt;P&gt;Thanks Sajid01 for your answer !&lt;/P&gt;&lt;P&gt;Indeed, it seems that we can't get values of the last column...&lt;/P&gt;&lt;P&gt;I hope someone will be able to give us a technical explanation for this problem.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2022 07:40:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-cannot-get-value-from-the-last-c-column/m-p/805447#M317290</guid>
      <dc:creator>v2rt</dc:creator>
      <dc:date>2022-04-01T07:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report : cannot get value from the last _c_ column.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-cannot-get-value-from-the-last-c-column/m-p/805449#M317291</link>
      <description>&lt;P&gt;In a compute block, you can only use variables that are to the left in the COLUMN statement. If you want a variable to show up before the variable that is used to compute it, you must create a "hidden" copy which you can use in the calculation:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report
  data=Contract
  split='00'x
  style(summary)=[color=cx3e3d73 backgroundcolor=BWH]
;
column Compagnie Date_export,(n=n1 Variation N);
define Compagnie / group missing order=INTERNAL style(Column)=[fontweight=bold backgroundcolor=Honeydew];
define Date_export / across order=INTERNAL  '';
define n1 / noprint;
define Variation / computed format=percent8.2 ;
define N / "N";
compute Variation;
  _c6_ = ((_c5_ - _c2_)/(_c2_));
  _c9_ = ((_c8_ - _c5_)/(_c5_));
  if _c6_ &amp;gt;0 then call define ('_c6_','style','style={color=green}'); else call define ('_c6_','style','style={color=red}');
  if _c9_ &amp;gt;0 then call define ('_c9_','style','style={color=green}'); else call define ('_c9_','style','style={color=red}');
endcomp;
rbreak after / summarize;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Apr 2022 07:44:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-cannot-get-value-from-the-last-c-column/m-p/805449#M317291</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-01T07:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report : cannot get value from the last _c_ column.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-cannot-get-value-from-the-last-c-column/m-p/805454#M317294</link>
      <description>&lt;P&gt;Thank you very much Kurt_Bremser for the explanation and the solution !&lt;/P&gt;&lt;P&gt;It works perfectly for me !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a nice day &lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2022 08:22:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-cannot-get-value-from-the-last-c-column/m-p/805454#M317294</guid>
      <dc:creator>v2rt</dc:creator>
      <dc:date>2022-04-01T08:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report : cannot get value from the last _c_ column.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-cannot-get-value-from-the-last-c-column/m-p/805471#M317298</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/421507"&gt;@v2rt&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively, you can perform your computations in a COMPUTE block of such a hidden ("dummy") column whose position in the COLUMN statement is to the right of the columns used in the COMPUTE block:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;PROC REPORT DATA=Contract SPLIT='00'x style(summary)=[color=cx3e3d73 backgroundcolor=BWH] ;
COLUMN Compagnie  Date_export , (Variation N) &lt;FONT color="#FF0000"&gt;dummy&lt;/FONT&gt;;
DEFINE Compagnie / GROUP MISSING ORDER=INTERNAL style(Column)=[fontweight=bold backgroundcolor=Honeydew];
DEFINE Date_export / ACROSS ORDER=INTERNAL  '';
DEFINE N / "N";
DEFINE Variation / COMPUTED format=percent8.2 ;
&lt;FONT color="#FF0000"&gt;DEFINE dummy / computed noprint;&lt;/FONT&gt;
compute &lt;FONT color="#FF0000"&gt;dummy&lt;/FONT&gt;;
	_c4_ = ((_c5_ - _c3_)/(_c3_));
	_c6_ = ((_c7_ - _c5_)/(_c5_));
if _c4_ &amp;gt;0 then call define ('_c4_','style','style={color=green}'); else call define ('_c4_','style','style={color=red}');
if _c6_ &amp;gt;0 then call define ('_c6_','style','style={color=green}'); else call define ('_c6_','style','style={color=red}');
endcomp;
RBREAK  AFTER  /SUMMARIZE;
RUN;&lt;/PRE&gt;
&lt;P&gt;This trick is presented in section 8.4.4 Using a Dummy Column to Consolidate Compute Blocks (p. 283 f.) of &lt;EM&gt;Carpenter's Guide to Innovative SAS Techniques&lt;/EM&gt; (see &lt;A href="https://support.sas.com/en/books/authors/art-carpenter.html" target="_blank" rel="noopener"&gt;https://support.sas.com/en/books/authors/art-carpenter.html&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2022 10:05:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-cannot-get-value-from-the-last-c-column/m-p/805471#M317298</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-04-01T10:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report : cannot get value from the last _c_ column.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-cannot-get-value-from-the-last-c-column/m-p/805473#M317299</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, it works too! It's maybe even cleaner because you don't have to skip "invisible" columns when you do the calculations in the compute.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the explanation of this tricks and for the reference!&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2022 10:35:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-cannot-get-value-from-the-last-c-column/m-p/805473#M317299</guid>
      <dc:creator>v2rt</dc:creator>
      <dc:date>2022-04-01T10:35:58Z</dc:date>
    </item>
  </channel>
</rss>

