<?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: Transpose one column into multiple columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Transpose-one-column-into-multiple-columns/m-p/710600#M218775</link>
    <description>&lt;P&gt;So you do not actually have a SAS data set yet apparently.&lt;/P&gt;
&lt;P&gt;To read the text output that look like that,&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;assuming&lt;/STRONG&gt; you always have exactly 3 groups of values you can read it with something similar to the following code.&lt;BR /&gt;The EXACTLY part is important as the / in the input statement below tells SAS to read the next value on the next line. Since SAS &lt;STRONG&gt;cannot&lt;/STRONG&gt; have variables with the same name this skips past the newr and newg values as essentially meaningless and counts the rounds. You have have not specified if the "value" are supposed to be character or numeric. The $ in the input indicates to read the data as character. If the values are actually numeric then you remove the $.&lt;/P&gt;
&lt;PRE&gt;data transpose;&lt;BR /&gt;   infile "path to your text file" ;
   Retain Round 1;
   input /
         /
         newr $
         /
         /
         newg1 $
         /
         /
         newg2 $
   ;
   output;
   round+1;
 
cards;
round1
newr
value1
newg
value2
newg
value3
round2
newr
value4
newg
value5
newg
value6
round3
newr
value7
newg
value8
newg
value9
;
run;&lt;/PRE&gt;
&lt;P&gt;If you are writing the FORTRAN I would strongly suggest using ONE ouput to write the value of Round and the three other variables on one line as that makes much more sense in general.&lt;/P&gt;</description>
    <pubDate>Mon, 11 Jan 2021 18:00:35 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-01-11T18:00:35Z</dc:date>
    <item>
      <title>Transpose one column into multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-one-column-into-multiple-columns/m-p/710579#M218763</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to transpose this column structure from round 1 to n:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;round1&lt;/P&gt;&lt;P&gt;newr&lt;/P&gt;&lt;P&gt;value1&lt;/P&gt;&lt;P&gt;newg&lt;/P&gt;&lt;P&gt;value2&lt;/P&gt;&lt;P&gt;newg&lt;/P&gt;&lt;P&gt;value3&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; n&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to the following one:&lt;/P&gt;&lt;P&gt;Round&amp;nbsp; &amp;nbsp;newer&amp;nbsp; &amp;nbsp; newg&amp;nbsp; &amp;nbsp; &amp;nbsp; newg&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; value1&amp;nbsp; &amp;nbsp;value2&amp;nbsp; &amp;nbsp; value3&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;n&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for any help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 15:31:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-one-column-into-multiple-columns/m-p/710579#M218763</guid>
      <dc:creator>Chira85</dc:creator>
      <dc:date>2021-01-11T15:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose one column into multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-one-column-into-multiple-columns/m-p/710584#M218766</link>
      <description>&lt;P&gt;Please provide your data example in the form of a data step. Please note: SAS will &lt;STRONG&gt;not&lt;/STRONG&gt; allow you to have two variables with the same name in a data set. So if "newg" is supposed to be a variable your want is not possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are there any other variables involved? If so you need to show what happens with them.&lt;/P&gt;
&lt;P&gt;You also need to show at least 2 and better 3 "examples" so we can tell what some of the "n" rows of data start with. Such things like is it &lt;STRONG&gt;always exactly&lt;/STRONG&gt; 3 sets of values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, make sure that what you show is what you mean. The message windows on this forum will reformat text and sometimes what is in the window doesn't quite match what was intended. &lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 15:40:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-one-column-into-multiple-columns/m-p/710584#M218766</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-11T15:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose one column into multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-one-column-into-multiple-columns/m-p/710591#M218769</link>
      <description>&lt;P&gt;Thank you for your response. The data I'am going to transpose is an output from another fortran program. Newg represents 2 variables. The data is:&lt;/P&gt;&lt;P&gt;data transpose;&lt;/P&gt;&lt;P&gt;input iteration;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;round1&lt;/P&gt;&lt;P&gt;newr&lt;/P&gt;&lt;P&gt;value1&lt;/P&gt;&lt;P&gt;newg&lt;/P&gt;&lt;P&gt;value2&lt;/P&gt;&lt;P&gt;newg&lt;/P&gt;&lt;P&gt;value3&lt;/P&gt;&lt;P&gt;round2&lt;/P&gt;&lt;P&gt;newr&lt;/P&gt;&lt;P&gt;value4&lt;/P&gt;&lt;P&gt;newg&lt;/P&gt;&lt;P&gt;value5&lt;/P&gt;&lt;P&gt;newg&lt;/P&gt;&lt;P&gt;value6&lt;/P&gt;&lt;P&gt;round3&lt;/P&gt;&lt;P&gt;newr&lt;/P&gt;&lt;P&gt;value7&lt;/P&gt;&lt;P&gt;newg&lt;/P&gt;&lt;P&gt;value8&lt;/P&gt;&lt;P&gt;newg&lt;/P&gt;&lt;P&gt;value9&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&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;</description>
      <pubDate>Mon, 11 Jan 2021 15:56:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-one-column-into-multiple-columns/m-p/710591#M218769</guid>
      <dc:creator>Chira85</dc:creator>
      <dc:date>2021-01-11T15:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose one column into multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-one-column-into-multiple-columns/m-p/710600#M218775</link>
      <description>&lt;P&gt;So you do not actually have a SAS data set yet apparently.&lt;/P&gt;
&lt;P&gt;To read the text output that look like that,&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;assuming&lt;/STRONG&gt; you always have exactly 3 groups of values you can read it with something similar to the following code.&lt;BR /&gt;The EXACTLY part is important as the / in the input statement below tells SAS to read the next value on the next line. Since SAS &lt;STRONG&gt;cannot&lt;/STRONG&gt; have variables with the same name this skips past the newr and newg values as essentially meaningless and counts the rounds. You have have not specified if the "value" are supposed to be character or numeric. The $ in the input indicates to read the data as character. If the values are actually numeric then you remove the $.&lt;/P&gt;
&lt;PRE&gt;data transpose;&lt;BR /&gt;   infile "path to your text file" ;
   Retain Round 1;
   input /
         /
         newr $
         /
         /
         newg1 $
         /
         /
         newg2 $
   ;
   output;
   round+1;
 
cards;
round1
newr
value1
newg
value2
newg
value3
round2
newr
value4
newg
value5
newg
value6
round3
newr
value7
newg
value8
newg
value9
;
run;&lt;/PRE&gt;
&lt;P&gt;If you are writing the FORTRAN I would strongly suggest using ONE ouput to write the value of Round and the three other variables on one line as that makes much more sense in general.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 18:00:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-one-column-into-multiple-columns/m-p/710600#M218775</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-11T18:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose one column into multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-one-column-into-multiple-columns/m-p/710754#M218851</link>
      <description>Thank you very much for your help. It works perfectly!&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Jan 2021 09:26:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-one-column-into-multiple-columns/m-p/710754#M218851</guid>
      <dc:creator>Chira85</dc:creator>
      <dc:date>2021-01-12T09:26:00Z</dc:date>
    </item>
  </channel>
</rss>

