<?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: Data transpose in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-transpose/m-p/870736#M343934</link>
    <description>&lt;P&gt;It looks like your data is read from a number of infiles, row by row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In that case, it may be (just guessing) that your data is grouped (but not sorted, because of the filename) already. Then it may be a possibility to use NOTSORTED:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=tall out=wide(drop=_name_);
by filename row notsorted;
id name;
var value;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But your output variables will still be character, as the input variable is character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to convert the data to numeric, you can code the stuff in a datastep, as suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;, although I would probably code it like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data wide;
  do until(last.row);
    set tall;
    by filename row notsorted;
    select(upcase(name));
       ...
       when('ICYTOTOXIC') Icytotoxic=input(value,1.);
       ...
       otherwise /* maybe write a warning in the log here */;
       end;
    end;
  drop name;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 20 Apr 2023 09:49:20 GMT</pubDate>
    <dc:creator>s_lassen</dc:creator>
    <dc:date>2023-04-20T09:49:20Z</dc:date>
    <item>
      <title>Data transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-transpose/m-p/870708#M343919</link>
      <description>&lt;P&gt;Is there a easier way to transpose a dataset from log to wide using proc sql that does not require sorting the dataset?&lt;/P&gt;&lt;P&gt;Can the transposed data automatically create numeric variables if all the values are such?&lt;BR /&gt;The example code is applied on the following dataset where some of the variables, such as "Isvariable" will only have numbers but they are appearing as character variables?&lt;BR /&gt;proc transpose data=tall out=wide(drop=_name_);&lt;BR /&gt;by filename row ;&lt;BR /&gt;id name;&lt;BR /&gt;var value;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bayzid_0-1681970576877.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/82859iC9F18FA9B66B7AFA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bayzid_0-1681970576877.png" alt="bayzid_0-1681970576877.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 06:03:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-transpose/m-p/870708#M343919</guid>
      <dc:creator>bayzid</dc:creator>
      <dc:date>2023-04-20T06:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: Data transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-transpose/m-p/870711#M343920</link>
      <description>&lt;P&gt;Since value is of type character, all transposed variables will also be character.&lt;/P&gt;
&lt;P&gt;Use a DATA step with SELECT:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by row;
retain
  /* put your new variables here */
;
if first.row then call missing (/*all newvariables*/);
select (name);
  ......
  when ('IsCytotoxic') iscytotoxic = input(value,1.);
  ......
end;
keep row /* all new variables */;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Apr 2023 06:15:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-transpose/m-p/870711#M343920</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-04-20T06:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: Data transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-transpose/m-p/870736#M343934</link>
      <description>&lt;P&gt;It looks like your data is read from a number of infiles, row by row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In that case, it may be (just guessing) that your data is grouped (but not sorted, because of the filename) already. Then it may be a possibility to use NOTSORTED:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=tall out=wide(drop=_name_);
by filename row notsorted;
id name;
var value;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But your output variables will still be character, as the input variable is character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to convert the data to numeric, you can code the stuff in a datastep, as suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;, although I would probably code it like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data wide;
  do until(last.row);
    set tall;
    by filename row notsorted;
    select(upcase(name));
       ...
       when('ICYTOTOXIC') Icytotoxic=input(value,1.);
       ...
       otherwise /* maybe write a warning in the log here */;
       end;
    end;
  drop name;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Apr 2023 09:49:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-transpose/m-p/870736#M343934</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2023-04-20T09:49:20Z</dc:date>
    </item>
  </channel>
</rss>

