<?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: Changing Data Output from Columns to Rows in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504790#M1024</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;Thanks a lot!!&lt;/P&gt;&lt;P&gt;I understood it better !!&lt;/P&gt;&lt;P&gt;I will read up about the implicit loop , I still didnt understand that part completely&lt;/P&gt;&lt;P&gt;do over j&lt;EM&gt;;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Inc_rain_snow=vname(j);&lt;/P&gt;&lt;P&gt;value=j&lt;EM&gt;;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For, Inc_rain_snow=vname(j), SAS would do :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;I&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;R&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;S&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;How will it know to put the areas(A,B,C,D) in the next column..(through the retain statement??)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Oct 2018 17:31:47 GMT</pubDate>
    <dc:creator>new_sas_user_4</dc:creator>
    <dc:date>2018-10-16T17:31:47Z</dc:date>
    <item>
      <title>Changing Data Output from Columns to Rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504400#M958</link>
      <description>&lt;P&gt;I get the following output :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Table1.PNG" style="width: 406px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24020iD046DC1BD2FB0464/image-size/large?v=v2&amp;amp;px=999" role="button" title="Table1.PNG" alt="Table1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I want the output as :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TableB.PNG" style="width: 292px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24022i026BA1D6D340F8B4/image-size/large?v=v2&amp;amp;px=999" role="button" title="TableB.PNG" alt="TableB.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Is there a way this can be done in SAS?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 17:50:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504400#M958</guid>
      <dc:creator>new_sas_user_4</dc:creator>
      <dc:date>2018-10-15T17:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Output from Columns to Rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504401#M959</link>
      <description>&lt;P&gt;Please paste values as plain text. I am unable to copy paste&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, try &lt;EM&gt;&lt;STRONG&gt;proc transpose&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 17:52:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504401#M959</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-15T17:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Output from Columns to Rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504408#M960</link>
      <description>&lt;P&gt;Area Income Rain Snow&lt;BR /&gt;A 10 100 1&lt;BR /&gt;B 20 200 2&lt;BR /&gt;C 30 300 3&lt;BR /&gt;D 40 400 4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Income A 10&lt;BR /&gt;Income B 20&lt;BR /&gt;Income C 30&lt;BR /&gt;Income D 40&lt;BR /&gt;Rain A 100&lt;BR /&gt;Rain B 200&lt;BR /&gt;Rain C 300&lt;BR /&gt;Rain D 400&lt;BR /&gt;Snow A 1&lt;BR /&gt;Snow B 2&lt;BR /&gt;Snow C 3&lt;BR /&gt;Snow D 4&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 18:01:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504408#M960</guid>
      <dc:creator>new_sas_user_4</dc:creator>
      <dc:date>2018-10-15T18:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Output from Columns to Rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504410#M961</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input Area $ Income Rain Snow;
cards;
A 10 100 1
B 20 200 2
C 30 300 3
D 40 400 4
;

proc transpose data=have out=_have;
by area;
var income--snow;
run;

proc sort data=_have out=want;
by _name_ area;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Oct 2018 18:06:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504410#M961</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-15T18:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Output from Columns to Rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504416#M962</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks Novinosrin!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output I get using this is :&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Table1.PNG" style="width: 153px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24023i6BC3CE29988E1FF8/image-size/large?v=v2&amp;amp;px=999" role="button" title="Table1.PNG" alt="Table1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BUt I want the output as :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TableB.PNG" style="width: 292px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24024iC6DF11E2B68900AC/image-size/large?v=v2&amp;amp;px=999" role="button" title="TableB.PNG" alt="TableB.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;AS in I want&amp;nbsp;Income/Rain/Snow to be the first Column&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 18:13:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504416#M962</guid>
      <dc:creator>new_sas_user_4</dc:creator>
      <dc:date>2018-10-15T18:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Output from Columns to Rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504420#M963</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Area $ Income Rain Snow;
cards;
A 10 100 1
B 20 200 2
C 30 300 3
D 40 400 4
;
data t;
retain Inc_rain_snow area value;
set have;
array j income--snow;
do over j;
Inc_rain_snow=vname(j);
value=j;
output;
end;
keep Inc_rain_snow area value;
run;
proc sort data=t out=want;
by Inc_rain_snow area;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Oct 2018 18:21:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504420#M963</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-15T18:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Output from Columns to Rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504423#M965</link>
      <description>&lt;P&gt;You rock Novinosrin!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you explain this solution pleaseeeee&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 18:32:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504423#M965</guid>
      <dc:creator>new_sas_user_4</dc:creator>
      <dc:date>2018-10-15T18:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Output from Columns to Rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504424#M966</link>
      <description>&lt;P&gt;I used datastep as opposed to proc transpose to do the same transpose, however datastep gives enormous flexibility by group the vars to transpose into a array and changing the shape from rows t columns or vice versa by doing the look up using a loop through all the elements of the array&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 18:36:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504424#M966</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-15T18:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Output from Columns to Rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504435#M968</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;BR /&gt;I didnt quite understand it 100percent, but thanks a lot:)&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 18:55:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504435#M968</guid>
      <dc:creator>new_sas_user_4</dc:creator>
      <dc:date>2018-10-15T18:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Output from Columns to Rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504436#M969</link>
      <description>&lt;P&gt;I will pen down a detailed explanation later after my midterm exam &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp; in 3 hours that is got nothing to do with sas. lol&lt;/P&gt;
&lt;P&gt;I shouldn't be even on sas communities today so plz accept my apology, SAS is so addictive , that I can't help.&amp;nbsp; Have a nice day!&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 18:58:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504436#M969</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-15T18:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Output from Columns to Rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504438#M971</link>
      <description>&lt;P&gt;hahah, yes, it is !! Please go ahead and prepare for your mid-term! Good Luck &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When you are back, read below and let me know if it makes sense..this is how I understand it:&lt;/P&gt;&lt;P&gt;data t;&amp;nbsp; &amp;nbsp; &amp;nbsp; // so here you are creating a new table which is blank at the moment but will hold values as you assign them?//&lt;BR /&gt;retain Inc_rain_snow area value;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// new column names ??//&lt;/P&gt;&lt;P&gt;set have;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //what does set do??//&lt;BR /&gt;array j income--snow;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //a blank array containing j(a variable) income rain snow(income rain snow from table have) ??&lt;BR /&gt;do over j;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//no idea what this means//&lt;BR /&gt;Inc_rain_snow=vname(j);&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//assigning j which is the first column in table "t" the name Inc_rain_snow ??//&lt;BR /&gt;value=j;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//how does this work?? How will the values be picked?? //&lt;BR /&gt;output;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //suppose this is part of syntax??//&lt;BR /&gt;end;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;/suppose this is part of syntax??//&lt;/SPAN&gt;&lt;BR /&gt;keep Inc_rain_snow area value;&lt;BR /&gt;run;&lt;BR /&gt;proc sort data=t out=want;&lt;BR /&gt;by Inc_rain_snow area;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If there is a source where I can understand this with the help of an example, please let me know &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 19:14:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504438#M971</guid>
      <dc:creator>new_sas_user_4</dc:creator>
      <dc:date>2018-10-15T19:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Output from Columns to Rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504460#M977</link>
      <description>&lt;P&gt;Why do you need to change the order of columns?&lt;/P&gt;
&lt;P&gt;The normal SAS "trick" to changing the order of the columns is to use a RETAIN statement, since it does not imply a type.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   retain _name_ area col1 ;
   set have;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you could use PROC SQL.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table want as 
  select 
 _name_
, area
, col1
  from have
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Oct 2018 19:44:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504460#M977</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-10-15T19:44:17Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Output from Columns to Rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504759#M1019</link>
      <description>&lt;P&gt;Good morning&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/213838"&gt;@new_sas_user_4&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your understanding is indeed in the right direction. Please find my responses in &lt;EM&gt;italics&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; t;&lt;EM&gt;*t is just the name i assigned for the transposed table;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;retain Inc_rain_snow area value&lt;EM&gt;;&lt;/EM&gt;&lt;EM&gt;*Yes new variables to create but this "retain" is not required, however since you specified the order the compiler &lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;creates the PDV and the output buffer;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;set have&lt;EM&gt;;&lt;/EM&gt;&lt;EM&gt;*reads records one by one from source table have;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;array j income--snow&lt;EM&gt;;&lt;/EM&gt;&lt;EM&gt;*groups then variables income rain and snow under one non-scalar value of the array name j;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;do over j&lt;EM&gt;;&lt;/EM&gt;&lt;EM&gt;*an implicit loop over the array element income--snow;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Inc_rain_snow=vname(j);&lt;EM&gt;*the name variable takes the name of the variable name of each element of the array;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;value=j&lt;EM&gt;;&lt;/EM&gt;&lt;EM&gt;*the new variable value takes the values of each element of the array;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;output;&lt;EM&gt;*explicit output writes the values to the output buffer/dataset for each iteration of the loop;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;end&lt;EM&gt;;&lt;/EM&gt;&lt;EM&gt;*of course ends the loop;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;keep Inc_rain_snow area value&lt;EM&gt;; &lt;/EM&gt;&lt;EM&gt;*keep only the variables of interest;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;/*The sort is just to get the order of the values to meet your requirement&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;So,sorting the temp table t to get the required table want*/&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sort&lt;/STRONG&gt; data=t out=want;&lt;/P&gt;
&lt;P&gt;by Inc_rain_snow area;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 15:37:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504759#M1019</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-16T15:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Output from Columns to Rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504790#M1024</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;Thanks a lot!!&lt;/P&gt;&lt;P&gt;I understood it better !!&lt;/P&gt;&lt;P&gt;I will read up about the implicit loop , I still didnt understand that part completely&lt;/P&gt;&lt;P&gt;do over j&lt;EM&gt;;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Inc_rain_snow=vname(j);&lt;/P&gt;&lt;P&gt;value=j&lt;EM&gt;;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For, Inc_rain_snow=vname(j), SAS would do :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;I&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;R&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;S&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;How will it know to put the areas(A,B,C,D) in the next column..(through the retain statement??)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 17:31:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504790#M1024</guid>
      <dc:creator>new_sas_user_4</dc:creator>
      <dc:date>2018-10-16T17:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Output from Columns to Rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504793#M1026</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/213838"&gt;@new_sas_user_4&lt;/a&gt;&amp;nbsp; How about using explicit array/loop like the below to make things clearer. The implicit loop does exactly the below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input Area $ Income Rain Snow;
cards;
A 10 100 1
B 20 200 2
C 30 300 3
D 40 400 4
;
data t;
retain Inc_rain_snow area value;
set have;
array j(*) income--snow;
do n=1 to 3;*3 elements in your array i.e income rain and snow;
Inc_rain_snow=vname(j(n));
value=j(n);
output;
end;
keep Inc_rain_snow area value;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;p&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 17:36:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504793#M1026</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-16T17:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Output from Columns to Rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504820#M1031</link>
      <description>&lt;P&gt;Thank you sooooooo much&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know this might be asking a bit too much , but &lt;U&gt;can you run 1 iteration for me:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;eg:&lt;/P&gt;&lt;P&gt;when n=1&lt;/P&gt;&lt;P&gt;inc_rain_snow would have the name of the&amp;nbsp;elements of the array which are :&lt;/P&gt;&lt;P&gt;Income&lt;/P&gt;&lt;P&gt;Rain&lt;/P&gt;&lt;P&gt;Snow&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how will be column &lt;STRONG&gt;area&lt;/STRONG&gt; get its value of&amp;nbsp;&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;STRONG&gt;value &lt;/STRONG&gt;(10,100,1)&amp;nbsp; (which is the first row in &lt;STRONG&gt;have table&lt;/STRONG&gt;) will get transposed when j=1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 18:30:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504820#M1031</guid>
      <dc:creator>new_sas_user_4</dc:creator>
      <dc:date>2018-10-16T18:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Output from Columns to Rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504822#M1032</link>
      <description>&lt;P&gt;Nothing is too much. I love these questions Gonna go out for lunch to give farewell to my classmate who just graduated. Will respond after lunch(Chicago time).Hang in there. Cheers&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 18:21:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504822#M1032</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-16T18:21:16Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Output from Columns to Rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504924#M1058</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/213838"&gt;@new_sas_user_4&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The set statement reads one record into a memory area known as program data vector that holds the observation while datastep is executed&lt;BR /&gt;So when &lt;STRONG&gt;set have&lt;/STRONG&gt; executes for the 1st time&lt;BR /&gt;&lt;STRONG&gt;A 10 100 1&lt;/STRONG&gt;&lt;BR /&gt;is read into memory and is held for further processing i.e using other statements that&lt;BR /&gt;follows set statement&lt;BR /&gt;Now let's get into the loop.&lt;BR /&gt;The index variable n when 1,&lt;BR /&gt;references the 1st element of the array as j(n)&amp;lt;=&amp;gt;income&lt;BR /&gt;Inc_rain_snow=vname(j(n));&lt;BR /&gt;this resolves to Inc_rain_snow=vname(j(1))&lt;BR /&gt;and that is Inc_rain_snow=vname(income);&lt;BR /&gt;similarly &lt;BR /&gt;value=j(n);&lt;BR /&gt;resolves to value=j(1); and that is value=income;&lt;BR /&gt;the rest of the variable values remain undisturbed and the output statment writes the &lt;BR /&gt;contents in the memory to the output dataset. The same happens for 3 iterations as we loop through&lt;BR /&gt;the 3 elements in the array. So the output statement executes thrice within the loop writing the&lt;BR /&gt;value of area A thrice.&lt;/P&gt;
&lt;P&gt;Once SAS has executed all the statements for the 1st records, the process repeats for the next record&lt;BR /&gt;until end of file as it goes back to the top of the datastep.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 22:16:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/504924#M1058</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-16T22:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Output from Columns to Rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/505225#M1123</link>
      <description>&lt;P&gt;Thank you so much&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;for taking the time to explain this &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I got it&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 17:14:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Data-Output-from-Columns-to-Rows/m-p/505225#M1123</guid>
      <dc:creator>new_sas_user_4</dc:creator>
      <dc:date>2018-10-17T17:14:36Z</dc:date>
    </item>
  </channel>
</rss>

