<?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 Retain the first line using first. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Retain-the-first-line-using-first/m-p/608874#M76680</link>
    <description>&lt;P&gt;I have a dataset named happy with only one variable.&lt;/P&gt;&lt;P&gt;It's like.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;x&lt;/P&gt;&lt;P&gt;2019&lt;/P&gt;&lt;P&gt;New Year&lt;/P&gt;&lt;P&gt;Happy&lt;/P&gt;&lt;P&gt;Good&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;as x is the variable name, I want a new dataset with 2019 as the year variable, and New Year as the first line in x.&lt;/P&gt;&lt;P&gt;It would be like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;x &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;year&lt;/P&gt;&lt;P&gt;New Year &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2019&lt;/P&gt;&lt;P&gt;Happy &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2019&lt;/P&gt;&lt;P&gt;Good &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2019&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I did was:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data new;&lt;BR /&gt;set happy;&lt;BR /&gt;retain year;&lt;BR /&gt;if first.x then year=y;&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;Why doesn't that work, and how would I make it work?&lt;/P&gt;</description>
    <pubDate>Mon, 02 Dec 2019 21:52:55 GMT</pubDate>
    <dc:creator>dupp99</dc:creator>
    <dc:date>2019-12-02T21:52:55Z</dc:date>
    <item>
      <title>Retain the first line using first.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Retain-the-first-line-using-first/m-p/608874#M76680</link>
      <description>&lt;P&gt;I have a dataset named happy with only one variable.&lt;/P&gt;&lt;P&gt;It's like.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;x&lt;/P&gt;&lt;P&gt;2019&lt;/P&gt;&lt;P&gt;New Year&lt;/P&gt;&lt;P&gt;Happy&lt;/P&gt;&lt;P&gt;Good&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;as x is the variable name, I want a new dataset with 2019 as the year variable, and New Year as the first line in x.&lt;/P&gt;&lt;P&gt;It would be like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;x &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;year&lt;/P&gt;&lt;P&gt;New Year &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2019&lt;/P&gt;&lt;P&gt;Happy &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2019&lt;/P&gt;&lt;P&gt;Good &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2019&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I did was:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data new;&lt;BR /&gt;set happy;&lt;BR /&gt;retain year;&lt;BR /&gt;if first.x then year=y;&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;Why doesn't that work, and how would I make it work?&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2019 21:52:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Retain-the-first-line-using-first/m-p/608874#M76680</guid>
      <dc:creator>dupp99</dc:creator>
      <dc:date>2019-12-02T21:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: Retain the first line using first.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Retain-the-first-line-using-first/m-p/608875#M76681</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input x &amp;amp; $10.;
cards;
2019
New Year
Happy
Good
;

data want;
set have;
retain year;
if _n_=1 then do;
year=x;
delete;
end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Dec 2019 21:59:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Retain-the-first-line-using-first/m-p/608875#M76681</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-12-02T21:59:42Z</dc:date>
    </item>
  </channel>
</rss>

