<?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: Use &amp;quot;firstobs&amp;quot; in DATA step to create lag for a single column instead of all the colum in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Use-quot-firstobs-quot-in-DATA-step-to-create-lag-for-a-single/m-p/635763#M188818</link>
    <description>&lt;P&gt;Here is . If you don't mind.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 set sashelp.class;
run;


proc transpose data=have(obs=0) out=temp;
var _all_;
run;
proc sql noprint;
select cats(_name_,'=_',_name_) into :rename separated by ' ' from temp;
quit;
data want;
 merge have have(firstobs=2 rename=(&amp;amp;rename));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 30 Mar 2020 10:45:50 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2020-03-30T10:45:50Z</dc:date>
    <item>
      <title>Use "firstobs" in DATA step to create lag for a single column instead of all the columns.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-quot-firstobs-quot-in-DATA-step-to-create-lag-for-a-single/m-p/635758#M188814</link>
      <description>&lt;P&gt;I use firstobs to create lag and merge it with existing data, but every time I have to rename all the columns as C1=_C1, C2=_C2 so that I can drop them easily since they are of no use to me.This is easy if the table has only 4-5 columns but I am working on datasets which have more than 50 columns.So I have to rename them all manually since I don't know how to use macros.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way through which I can create lag for a specific column of a table?&lt;/P&gt;</description>
      <pubDate>Mon, 30 Mar 2020 10:30:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-quot-firstobs-quot-in-DATA-step-to-create-lag-for-a-single/m-p/635758#M188814</guid>
      <dc:creator>Saurabh_Rana</dc:creator>
      <dc:date>2020-03-30T10:30:23Z</dc:date>
    </item>
    <item>
      <title>Re: Use "firstobs" in DATA step to create lag for a single column instead of all the colum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-quot-firstobs-quot-in-DATA-step-to-create-lag-for-a-single/m-p/635759#M188815</link>
      <description>IF your variables like C1 C2 .C10 .&lt;BR /&gt;could try :&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;merge have have( rename=(C1-C10 = _C1-_C10) );&lt;BR /&gt;run;</description>
      <pubDate>Mon, 30 Mar 2020 10:37:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-quot-firstobs-quot-in-DATA-step-to-create-lag-for-a-single/m-p/635759#M188815</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-03-30T10:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: Use "firstobs" in DATA step to create lag for a single column instead of all the colum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-quot-firstobs-quot-in-DATA-step-to-create-lag-for-a-single/m-p/635760#M188816</link>
      <description>No that was just a example I used to explain the question.&lt;BR /&gt;</description>
      <pubDate>Mon, 30 Mar 2020 10:38:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-quot-firstobs-quot-in-DATA-step-to-create-lag-for-a-single/m-p/635760#M188816</guid>
      <dc:creator>Saurabh_Rana</dc:creator>
      <dc:date>2020-03-30T10:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: Use "firstobs" in DATA step to create lag for a single column instead of all the colum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-quot-firstobs-quot-in-DATA-step-to-create-lag-for-a-single/m-p/635761#M188817</link>
      <description>Also is there a way to create lead instead of lag using firstobs or some other function in SAS.</description>
      <pubDate>Mon, 30 Mar 2020 10:42:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-quot-firstobs-quot-in-DATA-step-to-create-lag-for-a-single/m-p/635761#M188817</guid>
      <dc:creator>Saurabh_Rana</dc:creator>
      <dc:date>2020-03-30T10:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: Use "firstobs" in DATA step to create lag for a single column instead of all the colum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-quot-firstobs-quot-in-DATA-step-to-create-lag-for-a-single/m-p/635763#M188818</link>
      <description>&lt;P&gt;Here is . If you don't mind.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 set sashelp.class;
run;


proc transpose data=have(obs=0) out=temp;
var _all_;
run;
proc sql noprint;
select cats(_name_,'=_',_name_) into :rename separated by ' ' from temp;
quit;
data want;
 merge have have(firstobs=2 rename=(&amp;amp;rename));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Mar 2020 10:45:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-quot-firstobs-quot-in-DATA-step-to-create-lag-for-a-single/m-p/635763#M188818</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-03-30T10:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: Use "firstobs" in DATA step to create lag for a single column instead of all the colum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-quot-firstobs-quot-in-DATA-step-to-create-lag-for-a-single/m-p/635765#M188819</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/316224"&gt;@Saurabh_Rana&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;No that was just a example I used to explain the question.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then please post an excerpt of the data you have as usable data step, so that we don't have to guess what you have. And please show what you expect as result.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Mar 2020 10:47:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-quot-firstobs-quot-in-DATA-step-to-create-lag-for-a-single/m-p/635765#M188819</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-03-30T10:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: Use "firstobs" in DATA step to create lag for a single column instead of all the colum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-quot-firstobs-quot-in-DATA-step-to-create-lag-for-a-single/m-p/635766#M188820</link>
      <description>I can't mention the columns but what I am saying is that all the column names are completely different.</description>
      <pubDate>Mon, 30 Mar 2020 10:49:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-quot-firstobs-quot-in-DATA-step-to-create-lag-for-a-single/m-p/635766#M188820</guid>
      <dc:creator>Saurabh_Rana</dc:creator>
      <dc:date>2020-03-30T10:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: Use "firstobs" in DATA step to create lag for a single column instead of all the colum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-quot-firstobs-quot-in-DATA-step-to-create-lag-for-a-single/m-p/635775#M188824</link>
      <description>&lt;P&gt;You are &lt;STRONG&gt;NOT(!!!)&lt;/STRONG&gt; creating a lag, you create a look-ahead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the look-ahead table, use a keep= dataset option to keep only the column(s) needed:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
merge
  have
  have (keep=c rename=(c=_c))
;
/* further processing */
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Mar 2020 11:17:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-quot-firstobs-quot-in-DATA-step-to-create-lag-for-a-single/m-p/635775#M188824</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-30T11:17:56Z</dc:date>
    </item>
  </channel>
</rss>

