<?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: How to get a single line in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-single-line/m-p/41507#M8499</link>
    <description>Your newness to SAS is not the main issue here.  You need to specify what rule you want followed to collapse the nine obs you have shown to just one.&lt;BR /&gt;
&lt;BR /&gt;
I'll guess it is: for all obs with same ID, create one rec with first rec's start_dt and last rec's end_dt.&lt;BR /&gt;
&lt;BR /&gt;
Correct?&lt;BR /&gt;
&lt;BR /&gt;
Before you answer, note I did not say "first rec" by date or by current order in the data - I did not say either.  You must include this and every other imaginable detail in your specs.</description>
    <pubDate>Tue, 30 Nov 2010 18:58:53 GMT</pubDate>
    <dc:creator>Phrzby_Phil</dc:creator>
    <dc:date>2010-11-30T18:58:53Z</dc:date>
    <item>
      <title>How to get a single line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-single-line/m-p/41506#M8498</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Im fairly new to SAS and learning it, I have a dataset like,&lt;BR /&gt;
&lt;BR /&gt;
obs           ID                                 start_dt           end_dt&lt;BR /&gt;
&lt;BR /&gt;
  1    9000010130143072000000    20070801       20070831   &lt;BR /&gt;
  2    9000010130143072000000    20070901       20070930   &lt;BR /&gt;
  3    9000010130143072000000    20071001       20071031   &lt;BR /&gt;
  4    9000010130143072000000    20071101       20071130   &lt;BR /&gt;
  5    9000010130143072000000    20071201       20071231   &lt;BR /&gt;
  6    9000010130143072000000    20080101       20080131   &lt;BR /&gt;
  7    9000010130143072000000    20080201       20080229   &lt;BR /&gt;
  8    9000010130143072000000    20080301       20080331   &lt;BR /&gt;
  9    9000010130143072000000    20080401       20080430   &lt;BR /&gt;
 10    9000010130143072000000    20080501       20080531   &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
How can I convert it in a single record as below, &lt;BR /&gt;
&lt;BR /&gt;
obs           ID                                 start_dt           end_dt&lt;BR /&gt;
&lt;BR /&gt;
  1    9000010130143072000000    20070801       20080531   &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks,</description>
      <pubDate>Tue, 30 Nov 2010 18:27:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-single-line/m-p/41506#M8498</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-11-30T18:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a single line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-single-line/m-p/41507#M8499</link>
      <description>Your newness to SAS is not the main issue here.  You need to specify what rule you want followed to collapse the nine obs you have shown to just one.&lt;BR /&gt;
&lt;BR /&gt;
I'll guess it is: for all obs with same ID, create one rec with first rec's start_dt and last rec's end_dt.&lt;BR /&gt;
&lt;BR /&gt;
Correct?&lt;BR /&gt;
&lt;BR /&gt;
Before you answer, note I did not say "first rec" by date or by current order in the data - I did not say either.  You must include this and every other imaginable detail in your specs.</description>
      <pubDate>Tue, 30 Nov 2010 18:58:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-single-line/m-p/41507#M8499</guid>
      <dc:creator>Phrzby_Phil</dc:creator>
      <dc:date>2010-11-30T18:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a single line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-single-line/m-p/41508#M8500</link>
      <description>Are these data the whole content of your dataset?&lt;BR /&gt;
If it is, it is much achieved.&lt;BR /&gt;
[pre]&lt;BR /&gt;
data op;&lt;BR /&gt;
 set yourdataset end=last;&lt;BR /&gt;
 retain _start _obs ;&lt;BR /&gt;
 if _n_ eq 1 then do; _start=start_dt; _obs=obs;end;&lt;BR /&gt;
 if last then do; _end=end_dt; output; end;&lt;BR /&gt;
 keep _obs id _start _end;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
If you have a couple of groups of id ,then using 'first.id' 'last.id' to get it.&lt;BR /&gt;
&lt;BR /&gt;
It somewhat looks like the previous post in this forum?? Weird!!&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Wed, 01 Dec 2010 07:08:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-single-line/m-p/41508#M8500</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2010-12-01T07:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a single line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-single-line/m-p/41509#M8501</link>
      <description>this  is what I like about discussion forums: discovering how many different ways there might be to interpret a question ( let alone the number of ways to program the assumed answer)&lt;BR /&gt;
Here is it min(start) and max( end) or first.start and last.end &lt;BR /&gt;
or something else???</description>
      <pubDate>Wed, 01 Dec 2010 14:55:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-single-line/m-p/41509#M8501</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-12-01T14:55:39Z</dc:date>
    </item>
  </channel>
</rss>

