<?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 transpose with static variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose-with-static-variable/m-p/757078#M239056</link>
    <description>&lt;P&gt;Its working! Thank you so much! So far I didnt work with proc sql, but obviously its pretty powerful &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; Thx!&lt;/P&gt;</description>
    <pubDate>Tue, 27 Jul 2021 08:48:50 GMT</pubDate>
    <dc:creator>Konkordanz</dc:creator>
    <dc:date>2021-07-27T08:48:50Z</dc:date>
    <item>
      <title>Proc transpose with static variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose-with-static-variable/m-p/757065#M239044</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;ive the following Data-Set:&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;Year&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;bev&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;V01&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;V02&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;V03&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Vn&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;4063400&lt;/TD&gt;&lt;TD&gt;7399&lt;/TD&gt;&lt;TD&gt;7146&lt;/TD&gt;&lt;TD&gt;4120&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2019&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;3889&lt;/TD&gt;&lt;TD&gt;3750&lt;/TD&gt;&lt;TD&gt;2220&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2020&lt;/TD&gt;&lt;TD&gt;4063400&lt;/TD&gt;&lt;TD&gt;3510&lt;/TD&gt;&lt;TD&gt;3397&lt;/TD&gt;&lt;TD&gt;1900&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;What I want is: Transpose all variables except of the empty line. The Var &lt;EM&gt;Bev&lt;/EM&gt; should has a static value over all rows.&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;Year&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;bev&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;V01&lt;/TD&gt;&lt;TD&gt;3889&lt;/TD&gt;&lt;TD&gt;3510&lt;/TD&gt;&lt;TD&gt;4063400&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;V02&lt;/TD&gt;&lt;TD&gt;3750&lt;/TD&gt;&lt;TD&gt;3397&lt;/TD&gt;&lt;TD&gt;4063400&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;V03&lt;/TD&gt;&lt;TD&gt;2220&lt;/TD&gt;&lt;TD&gt;1900&lt;/TD&gt;&lt;TD&gt;4063400&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Vn&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;Ive tried it with this Code. The Result looks fine, but it doesnt creates the column &lt;EM&gt;Bev&lt;/EM&gt;. Would be great to get some help! &lt;STRONG&gt;Thank you!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=test Name=Kontonummer präfix=Jahr out=test;
id Jahr;
var v01-v89;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jul 2021 07:21:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose-with-static-variable/m-p/757065#M239044</guid>
      <dc:creator>Konkordanz</dc:creator>
      <dc:date>2021-07-27T07:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose with static variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose-with-static-variable/m-p/757068#M239046</link>
      <description>&lt;P&gt;Except for the special variable like _name_ that might be added by proc transpose it will not create new values. You have to either populate that Bev value prior to the transpose or after, whichever makes more sense or is easiest.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jul 2021 07:27:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose-with-static-variable/m-p/757068#M239046</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-07-27T07:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose with static variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose-with-static-variable/m-p/757071#M239049</link>
      <description>&lt;P&gt;You will need an additional step to set bev:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines dlm=" " dsd truncover;
input Year bev V01 V02 V03;
datalines;
 4063400 7399 7146 4120
2019  3889 3750 2220 
2020 4063400 3510 3397 1900
;

proc sql noprint;
select max(bev) into :bev from have;
quit;

proc transpose
  data=have
  out=trans (rename=(_name_=year))
  prefix=Y_
;
var V:;
id year;
run;

data want;
set trans;
bev = &amp;amp;bev;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Data is presented as a data step with datalines, which makes it ver easy for everyone reading this to recreate the dataset without second guessing attributes or content. Please do so yourself in the future.&lt;/LI&gt;
&lt;LI&gt;How you determine the value for bev may be different (e.g. from the first observation of have).&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jul 2021 07:57:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose-with-static-variable/m-p/757071#M239049</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-07-27T07:57:55Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose with static variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose-with-static-variable/m-p/757078#M239056</link>
      <description>&lt;P&gt;Its working! Thank you so much! So far I didnt work with proc sql, but obviously its pretty powerful &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; Thx!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jul 2021 08:48:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose-with-static-variable/m-p/757078#M239056</guid>
      <dc:creator>Konkordanz</dc:creator>
      <dc:date>2021-07-27T08:48:50Z</dc:date>
    </item>
  </channel>
</rss>

