<?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 - creating a new variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-report-creating-a-new-variable/m-p/753484#M237490</link>
    <description>&lt;P&gt;Thx for answering! This would be problematic, cause my dataset contains secret data.&lt;/P&gt;&lt;P&gt;Basically it would be very helpful, to get just one solution for the follow question:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need a macro-order in the head of the code, that put out a specific value of the base dataset. This value should be integrated in my formular. Something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Test;
set FILE_XY;
Betrag_t=betrag/1000;
%let EXAMPLE (bev=if Sitz=... &amp;amp; Jahr=2020)²
run;

proc report Data=test;
column land Jahr je_Einw, betrag_t;
define land /group "Art der Zahlg";
define Jahr /across "01.01. - 31.12." style={cellwidth=3 cm};
define betrag_t /analysis "1.000 €" sum Format=16.2;
define je_Einw / computed;
compute je_Einw;
je_Einw=betrag_t/&amp;amp;EXAMPLE;
endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;² Definition&lt;/STRONG&gt;: I dont know, how to use a makro-order like this...the &lt;STRONG&gt;&lt;EM&gt;Example&lt;/EM&gt;&lt;/STRONG&gt;-Value that has to be integrated in the formular is coupled to a if-condition. This prder means: Take the value of the Variable &lt;EM&gt;bev&amp;nbsp;&lt;/EM&gt;if the variable &lt;EM&gt;Sitz&lt;/EM&gt;= XY and the Variable &lt;EM&gt;Jahr&lt;/EM&gt;=2020. Is this possible with the %let-Order?&lt;/P&gt;</description>
    <pubDate>Mon, 12 Jul 2021 12:32:14 GMT</pubDate>
    <dc:creator>Konkordanz</dc:creator>
    <dc:date>2021-07-12T12:32:14Z</dc:date>
    <item>
      <title>proc report - creating a new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-creating-a-new-variable/m-p/753446#M237467</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a new variable within the proc-report-command.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first aim is: for every Land and year it should sum the Euro-amount. Each country can occur more than once. Until now my table contents following Variables:&lt;/P&gt;&lt;P&gt;The Var &lt;EM&gt;land&lt;/EM&gt; should be the group-var of column A.&lt;/P&gt;&lt;P&gt;The Var &lt;EM&gt;Jahr &lt;/EM&gt;contents 2019 and 2020. 2019 is column B und 2020 is column C.&lt;/P&gt;&lt;P&gt;The Var &lt;EM&gt;betrag_t&lt;/EM&gt; is the analysisvariable in Euro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This first aim works with this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report Data=test
column land Jahr, betrag_t;
define land / group;
define Jahr / across "01.01. - 31.12." style={cellwidth=3 cm};
define betrag_t  / analysis "1.000 €" sum Format=16.2;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The Result:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;land&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;2019&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;2020&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;…€&lt;/TD&gt;&lt;TD&gt;…€&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;…&lt;/TD&gt;&lt;TD&gt;…&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;…&lt;/TD&gt;&lt;TD&gt;…&lt;/TD&gt;&lt;TD&gt;…&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second aim is my problem: I want to create a new variable and I dont know how to do that.&lt;/P&gt;&lt;P&gt;In my base dataset there is also the variable &lt;EM&gt;bev&lt;/EM&gt;. These contains the population size of each land. The new variable with the name &lt;EM&gt;je_Einw&lt;/EM&gt;&amp;nbsp; should be the result of the formel: &lt;STRONG&gt;betrag_t/bev&lt;/STRONG&gt;. (€ per Person)&lt;/P&gt;&lt;P&gt;The final aim is a table like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Land&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;2019&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;2020&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;2020 - per person&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;…€&lt;/TD&gt;&lt;TD&gt;…€&lt;/TD&gt;&lt;TD&gt;…€&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;…&lt;/TD&gt;&lt;TD&gt;…&lt;/TD&gt;&lt;TD&gt;…&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;…&lt;/TD&gt;&lt;TD&gt;…&lt;/TD&gt;&lt;TD&gt;…&lt;/TD&gt;&lt;TD&gt;…&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried it many times...but it doesnt work. For example with this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report Data=test;
column land Jahr je_Einw, betrag_t;
define land /group "Art der Zahlg";
define Jahr /across "01.01. - 31.12." style={cellwidth=3 cm};
define betrag_t /analysis "1.000 €" sum Format=16.2;
define je_Einw / computed;
compute je_Einw;
je_Einw=betrag_t/bev;
endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The Error says:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;ERROR: There is more than one ANALYSIS usage associated with&lt;BR /&gt;the column defined by the following elements.&lt;BR /&gt;Name Usage&lt;BR /&gt;-------------------------------- --------&lt;BR /&gt;je_Einw&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; COMPUTED&lt;BR /&gt;Betrag_t&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ANALYSE&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Im a newbe in SAS but I really want to learn it. Therefore I need some help. Would be awesome to get some &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Thank you!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 09:14:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-creating-a-new-variable/m-p/753446#M237467</guid>
      <dc:creator>Konkordanz</dc:creator>
      <dc:date>2021-07-12T09:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: proc report - creating a new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-creating-a-new-variable/m-p/753468#M237478</link>
      <description>&lt;P&gt;Can you provide a portion of data set TEST as a SAS data step? Please follow these instructions:&amp;nbsp;&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_blank"&gt;https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 11:57:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-creating-a-new-variable/m-p/753468#M237478</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-12T11:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: proc report - creating a new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-creating-a-new-variable/m-p/753484#M237490</link>
      <description>&lt;P&gt;Thx for answering! This would be problematic, cause my dataset contains secret data.&lt;/P&gt;&lt;P&gt;Basically it would be very helpful, to get just one solution for the follow question:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need a macro-order in the head of the code, that put out a specific value of the base dataset. This value should be integrated in my formular. Something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Test;
set FILE_XY;
Betrag_t=betrag/1000;
%let EXAMPLE (bev=if Sitz=... &amp;amp; Jahr=2020)²
run;

proc report Data=test;
column land Jahr je_Einw, betrag_t;
define land /group "Art der Zahlg";
define Jahr /across "01.01. - 31.12." style={cellwidth=3 cm};
define betrag_t /analysis "1.000 €" sum Format=16.2;
define je_Einw / computed;
compute je_Einw;
je_Einw=betrag_t/&amp;amp;EXAMPLE;
endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;² Definition&lt;/STRONG&gt;: I dont know, how to use a makro-order like this...the &lt;STRONG&gt;&lt;EM&gt;Example&lt;/EM&gt;&lt;/STRONG&gt;-Value that has to be integrated in the formular is coupled to a if-condition. This prder means: Take the value of the Variable &lt;EM&gt;bev&amp;nbsp;&lt;/EM&gt;if the variable &lt;EM&gt;Sitz&lt;/EM&gt;= XY and the Variable &lt;EM&gt;Jahr&lt;/EM&gt;=2020. Is this possible with the %let-Order?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 12:32:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-creating-a-new-variable/m-p/753484#M237490</guid>
      <dc:creator>Konkordanz</dc:creator>
      <dc:date>2021-07-12T12:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: proc report - creating a new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-creating-a-new-variable/m-p/753488#M237493</link>
      <description>&lt;P&gt;Make up some data, where every variable has a random value (or even, every variable has a value of 1)&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 12:38:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-creating-a-new-variable/m-p/753488#M237493</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-12T12:38:46Z</dc:date>
    </item>
  </channel>
</rss>

