<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/transpose/m-p/761857#M241141</link>
    <description>&lt;P&gt;Hi Ballardw&lt;/P&gt;&lt;P&gt;Thank you again for your answer&lt;/P&gt;&lt;P&gt;With&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data have;
  infile datalines dlm='\';
  informat name $12. ;
  input name @@ ;
  name=strip(name);
datalines;
ana\ marc\ rose
mary \sa \ann \marie paul
ines
;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my program works perfectly&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you again!!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 16 Aug 2021 16:15:51 GMT</pubDate>
    <dc:creator>Teresa12</dc:creator>
    <dc:date>2021-08-16T16:15:51Z</dc:date>
    <item>
      <title>transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/transpose/m-p/761810#M241120</link>
      <description>&lt;P&gt;&lt;BR /&gt;Hi&lt;BR /&gt;I need to transpose a dataset and I don't know how to do it&lt;/P&gt;&lt;P&gt;I have&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;length names $50.;&lt;BR /&gt;input names $ ;&lt;BR /&gt;datalines;&lt;BR /&gt;ana\ marc\ rose&lt;BR /&gt;mary \sa \ann \marie paul&lt;BR /&gt;ines&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;and I want a dataset :&lt;/P&gt;&lt;P&gt;Names&lt;BR /&gt;ana&lt;BR /&gt;marc&lt;BR /&gt;rose&lt;BR /&gt;mary&lt;BR /&gt;sa&lt;BR /&gt;ann&lt;BR /&gt;marie paul&lt;BR /&gt;ines&lt;/P&gt;&lt;P&gt;Thank you !!!&lt;/P&gt;</description>
      <pubDate>Mon, 16 Aug 2021 14:04:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/transpose/m-p/761810#M241120</guid>
      <dc:creator>Teresa12</dc:creator>
      <dc:date>2021-08-16T14:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/transpose/m-p/761821#M241123</link>
      <description>&lt;P&gt;"Transpose" would mean to rearrange variable positions. You want to split values out of a variable and not move them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, make sure that your data step will create values properly.&lt;/P&gt;
&lt;P&gt;You don't mention any other variables so this could be done by reading the data properly to begin with. Example:&lt;/P&gt;
&lt;PRE&gt;data have;
  infile datalines dlm='\';
  informat name $12. ;
  input name @@ ;
  name=strip(name);
datalines;
ana\ marc\ rose
mary \sa \ann \marie paul
ines
;

&lt;/PRE&gt;
&lt;P&gt;The @@ on the input reads from the line until exhausted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming that you have a more complicated issue and your existing data set has multiple values in a single variable:&lt;/P&gt;
&lt;PRE&gt;data have;
   infile datalines dlm=',';
length names $50.;
input names $ ;
datalines;
ana\ marc\ rose
mary \sa \ann \marie paul
ines
;

data want;
   set have;
   length name $ 12;
   do i=1 to countw(names,'\');
      name= strip(scan(names,i,'\'));
      output;
   end;&lt;BR /&gt;   drop i;
run;&lt;/PRE&gt;
&lt;P&gt;The delimiter in the Have set allows us to read the data as a single variable.&lt;/P&gt;
&lt;P&gt;The Want data set counts how many individual names are separated by the \ character, then uses Scan to pull each one out. Strip is to remove leading spaces that would occur.&lt;/P&gt;
&lt;P&gt;The output in the loop writes to the output data set once for each name scanned.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Aug 2021 14:45:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/transpose/m-p/761821#M241123</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-08-16T14:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/transpose/m-p/761829#M241126</link>
      <description>&lt;P&gt;Ballardaw, thank you very much for your answer, It works!!!&lt;/P&gt;&lt;P&gt;Thank you for your explanation!!&lt;/P&gt;&lt;P&gt;The only problem now, when the line starts by&amp;nbsp;\, the column Name is missing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data have;
   infile datalines dlm=',';
length names $50.;
input names $ ;
datalines;
ana\ marc\ rose
mary \sa \ann \marie paul
ines&lt;BR /&gt;\bert \tt
;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Aug 2021 15:03:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/transpose/m-p/761829#M241126</guid>
      <dc:creator>Teresa12</dc:creator>
      <dc:date>2021-08-16T15:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/transpose/m-p/761833#M241128</link>
      <description>&lt;P&gt;Note that I renamed the variable to NAME in my data step to read the individual names because now it only had one name and used the @@ to read multiple values from a single line of text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have a question about code that you run the best practice to copy the code and any messages from the log, open a text box on the forum using the &amp;lt;/&amp;gt; icon above the message window and then paste the code and messages. That way we can see exactly what code you ran and answer questions.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Aug 2021 15:14:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/transpose/m-p/761833#M241128</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-08-16T15:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/transpose/m-p/761857#M241141</link>
      <description>&lt;P&gt;Hi Ballardw&lt;/P&gt;&lt;P&gt;Thank you again for your answer&lt;/P&gt;&lt;P&gt;With&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data have;
  infile datalines dlm='\';
  informat name $12. ;
  input name @@ ;
  name=strip(name);
datalines;
ana\ marc\ rose
mary \sa \ann \marie paul
ines
;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my program works perfectly&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you again!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Aug 2021 16:15:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/transpose/m-p/761857#M241141</guid>
      <dc:creator>Teresa12</dc:creator>
      <dc:date>2021-08-16T16:15:51Z</dc:date>
    </item>
  </channel>
</rss>

