<?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 How to input data from one row to one variable? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-input-data-from-one-row-to-one-variable/m-p/775341#M246453</link>
    <description>&lt;P&gt;How should I write code so I can have program A behave as program B?&lt;/P&gt;
&lt;P&gt;Program A:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  &amp;lt;insert code here&amp;gt;;
  cards;
7  8.3  10.5  9  5.1  8.2  10.2  10.3  7.1  5.9
7.9  8.2  9.6  9  6.5  7.3  10.2  10.6  6.3  5.2
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Program B:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data test;
  input x y;
  cards;
7    7.9
8.3  8.2
10.5 9.6
9    9
5.1  6.5
8.2  7.3
10.2 10.2
10.3 10.6
7.1  6.3
5.9  5.2
;
run;&lt;/PRE&gt;
&lt;P&gt;Thanks for any hint.&lt;/P&gt;</description>
    <pubDate>Wed, 20 Oct 2021 09:36:45 GMT</pubDate>
    <dc:creator>whymath</dc:creator>
    <dc:date>2021-10-20T09:36:45Z</dc:date>
    <item>
      <title>How to input data from one row to one variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-input-data-from-one-row-to-one-variable/m-p/775341#M246453</link>
      <description>&lt;P&gt;How should I write code so I can have program A behave as program B?&lt;/P&gt;
&lt;P&gt;Program A:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  &amp;lt;insert code here&amp;gt;;
  cards;
7  8.3  10.5  9  5.1  8.2  10.2  10.3  7.1  5.9
7.9  8.2  9.6  9  6.5  7.3  10.2  10.6  6.3  5.2
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Program B:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data test;
  input x y;
  cards;
7    7.9
8.3  8.2
10.5 9.6
9    9
5.1  6.5
8.2  7.3
10.2 10.2
10.3 10.6
7.1  6.3
5.9  5.2
;
run;&lt;/PRE&gt;
&lt;P&gt;Thanks for any hint.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 09:36:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-input-data-from-one-row-to-one-variable/m-p/775341#M246453</guid>
      <dc:creator>whymath</dc:creator>
      <dc:date>2021-10-20T09:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to input data from one row to one variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-input-data-from-one-row-to-one-variable/m-p/775344#M246455</link>
      <description>I have tried "input #1 x @ #2 y @;", just one row is successfully readed. &amp;gt;_&amp;lt;</description>
      <pubDate>Wed, 20 Oct 2021 09:45:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-input-data-from-one-row-to-one-variable/m-p/775344#M246455</guid>
      <dc:creator>whymath</dc:creator>
      <dc:date>2021-10-20T09:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to input data from one row to one variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-input-data-from-one-row-to-one-variable/m-p/775345#M246456</link>
      <description>&lt;P&gt;The most simple application of PROC TRANSPOSE:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input var1-var10;
datalines;
7  8.3  10.5  9  5.1  8.2  10.2  10.3  7.1  5.9
7.9  8.2  9.6  9  6.5  7.3  10.2  10.6  6.3  5.2
;

proc transpose data=have out=long (drop=_name_);
var var:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Oct 2021 09:46:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-input-data-from-one-row-to-one-variable/m-p/775345#M246456</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-20T09:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to input data from one row to one variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-input-data-from-one-row-to-one-variable/m-p/775348#M246457</link>
      <description>Fine but is there a more awesome answer?</description>
      <pubDate>Wed, 20 Oct 2021 09:53:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-input-data-from-one-row-to-one-variable/m-p/775348#M246457</guid>
      <dc:creator>whymath</dc:creator>
      <dc:date>2021-10-20T09:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to input data from one row to one variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-input-data-from-one-row-to-one-variable/m-p/775349#M246458</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
dowhatiwant;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Really, the TRANSPOSE is the most simple and flexible code; in a single data step, you would have to write repeating LAGx() functions for all variables (repeated for n-1 times, where n is the number of observations in the source dataset). Which means you need an additional step anyway to get the observation number.&lt;/P&gt;
&lt;P&gt;Or you load the whole dataset into a hash object and transpose it from there, which also means LOTS of code.&lt;/P&gt;
&lt;P&gt;Let SAS do the work for you.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 09:59:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-input-data-from-one-row-to-one-variable/m-p/775349#M246458</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-20T09:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to input data from one row to one variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-input-data-from-one-row-to-one-variable/m-p/775351#M246459</link>
      <description>Very reasonable, I'll recept your solution.</description>
      <pubDate>Wed, 20 Oct 2021 10:11:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-input-data-from-one-row-to-one-variable/m-p/775351#M246459</guid>
      <dc:creator>whymath</dc:creator>
      <dc:date>2021-10-20T10:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to input data from one row to one variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-input-data-from-one-row-to-one-variable/m-p/775357#M246461</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/270406"&gt;@whymath&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Fine but is there a more awesome answer?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/270406"&gt;@whymath&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you mean a solution using a single (more complicated) DATA step like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
infile cards col=c;
input @;
_n=countw(_infile_,' ');
do _i=1 to _n;
  input #1 @_x x @;
  _x=c;
  input #2 @_y y @;
  _y=c;
  output;
end;
drop _:;
cards;
7  8.3  10.5  9  5.1  8.2  10.2  10.3  7.1  5.9
7.9  8.2  9.6  9  6.5  7.3  10.2  10.6  6.3  5.2
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Oct 2021 10:42:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-input-data-from-one-row-to-one-variable/m-p/775357#M246461</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-10-20T10:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to input data from one row to one variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-input-data-from-one-row-to-one-variable/m-p/775407#M246481</link>
      <description>Impressive! I hardly use the option 'col='. Thank you very much, my friend.</description>
      <pubDate>Wed, 20 Oct 2021 14:06:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-input-data-from-one-row-to-one-variable/m-p/775407#M246481</guid>
      <dc:creator>whymath</dc:creator>
      <dc:date>2021-10-20T14:06:58Z</dc:date>
    </item>
  </channel>
</rss>

