<?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 First variable of dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/First-variable-of-dataset/m-p/649142#M194574</link>
    <description>&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to sort the variables by mif, ddstl, src_ref. But then I need to output from this dataset only the first variable by mif and src_ref.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you help me?&amp;nbsp; I tried this, but not the result which I want&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=work.QUERY_FOR_ACTIVITY_0008 out=work.skuska;
by mif descending ddstl src_ref;
run;

data work.pokus;
set WORK.skuska;

by mif src_ref;
if first.src_ref then output;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is table&amp;nbsp; - I want this yellow rows only:&lt;/P&gt;&lt;P&gt;src_ref can be more then twice in the table, but only with very similar time- difference 40sec.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/39654iB1B14264D9E43073/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 20 May 2020 09:58:07 GMT</pubDate>
    <dc:creator>Laylitta</dc:creator>
    <dc:date>2020-05-20T09:58:07Z</dc:date>
    <item>
      <title>First variable of dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-variable-of-dataset/m-p/649142#M194574</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to sort the variables by mif, ddstl, src_ref. But then I need to output from this dataset only the first variable by mif and src_ref.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you help me?&amp;nbsp; I tried this, but not the result which I want&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=work.QUERY_FOR_ACTIVITY_0008 out=work.skuska;
by mif descending ddstl src_ref;
run;

data work.pokus;
set WORK.skuska;

by mif src_ref;
if first.src_ref then output;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is table&amp;nbsp; - I want this yellow rows only:&lt;/P&gt;&lt;P&gt;src_ref can be more then twice in the table, but only with very similar time- difference 40sec.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/39654iB1B14264D9E43073/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 09:58:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-variable-of-dataset/m-p/649142#M194574</guid>
      <dc:creator>Laylitta</dc:creator>
      <dc:date>2020-05-20T09:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: First variable of dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-variable-of-dataset/m-p/649143#M194575</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/329873"&gt;@Laylitta&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is no yellow rows&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Could you please update your post with the last part?&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 09:44:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-variable-of-dataset/m-p/649143#M194575</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-05-20T09:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: First variable of dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-variable-of-dataset/m-p/649144#M194576</link>
      <description>&lt;P&gt;Change the BY statement in the sort to this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;by mif src_ref descending ddstl;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 May 2020 09:45:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-variable-of-dataset/m-p/649144#M194576</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-20T09:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: First variable of dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-variable-of-dataset/m-p/649146#M194577</link>
      <description>I already updated, I dont know, why it doesn´t upload - I tried it twice, but now I hope, you will see the picture.</description>
      <pubDate>Wed, 20 May 2020 09:48:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-variable-of-dataset/m-p/649146#M194577</guid>
      <dc:creator>Laylitta</dc:creator>
      <dc:date>2020-05-20T09:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: First variable of dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-variable-of-dataset/m-p/649147#M194578</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/329873"&gt;@Laylitta&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We can see the rows now&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Please try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;by mif descending src_ref;
if last.src_ref then output;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 09:52:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-variable-of-dataset/m-p/649147#M194578</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-05-20T09:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: First variable of dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-variable-of-dataset/m-p/649148#M194579</link>
      <description>This solution will not works for me. Because the key is ddstl. The observations are 2 together with just the differenct 40sec, but I need just one from them. If I will sort the first by src_ref, they can be e.g. 10 observations. The first two will have the date and time e.g. 5may10:15:30 and 5may 10:16:10 and the other two will have 8may10:30:40 and 8may10:31:20.</description>
      <pubDate>Wed, 20 May 2020 09:53:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-variable-of-dataset/m-p/649148#M194579</guid>
      <dc:creator>Laylitta</dc:creator>
      <dc:date>2020-05-20T09:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: First variable of dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-variable-of-dataset/m-p/649157#M194586</link>
      <description>&lt;P&gt;You will need to use LAG() because you are ignoring a sorted level.&amp;nbsp; There is a possibility your expectations of when src_ref changes will be subverted, especially if src_ref 'bounces around' on a given date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  by mif;&lt;BR /&gt;  if first.mif or src_ref ne lag(src_ref);
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 10:53:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-variable-of-dataset/m-p/649157#M194586</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-05-20T10:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: First variable of dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-variable-of-dataset/m-p/649182#M194598</link>
      <description>&lt;P&gt;Why all the hassle with pictures? If you posted your data AS RECOMMENDED(!) in a data step with datalines, it only takes a copy/paste into a "little running man" window. No separate uploading necessary. And you can mark lines in the text with additional "data" that is not read.&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 12:01:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-variable-of-dataset/m-p/649182#M194598</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-20T12:01:12Z</dc:date>
    </item>
  </channel>
</rss>

