<?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: question about specific selection in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/question-about-specific-selection/m-p/93756#M26590</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you only want to narrow the results of your previous run to only the earliest test_date, and you've already run the code, couldn't you just run something like the following on the file you originally produced:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table really_want as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select * from want&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by id&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; having test_date eq min(test_date)&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 Aug 2012 21:31:47 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2012-08-14T21:31:47Z</dc:date>
    <item>
      <title>question about specific selection</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/question-about-specific-selection/m-p/93755#M26589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Following up the question in my previous post, I would like to ask if any sas expert can help me on this simple question.&lt;/P&gt;&lt;P&gt;I’d like to know how many total excise times for each person six months before the 1&lt;SUP&gt;st&lt;/SUP&gt; test_date when 2&amp;lt;=score&amp;lt;=4. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BTW, thanks again Haikuo and Arthur for your help on my previous question.&amp;nbsp; Much appreciate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; @&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; id @&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; test_date &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: teal; font-size: 10pt;"&gt;yymmdd10.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; @&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;13&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; score;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; test_date &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: teal; font-size: 10pt;"&gt;yymmdd10.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;004 20050615 9&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;001 20021120 2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;002 20030128 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;005 20040917 9&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;003 20040314 6&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;001 20030523 7&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;004 20001225 5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;005 20061225 4&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;002 20010807 7&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;001 20031010 4&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; exercise;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; @&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; id @&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;5&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; exercise_date &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: teal; font-size: 10pt;"&gt;yymmdd10.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; exercise_date &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: teal; font-size: 10pt;"&gt;yymmdd10.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;001 20011206&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;001 20030806&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;010 20030526&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;001 20020728&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;008 20051223&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;002 20021127&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;003 20040527&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;002 20020901&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;005 20050728&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;005 20050925&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;002 20041002&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;006 20061112&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;001 20020928&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;001 20030905&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Aug 2012 20:52:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/question-about-specific-selection/m-p/93755#M26589</guid>
      <dc:creator>user1</dc:creator>
      <dc:date>2012-08-14T20:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: question about specific selection</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/question-about-specific-selection/m-p/93756#M26590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you only want to narrow the results of your previous run to only the earliest test_date, and you've already run the code, couldn't you just run something like the following on the file you originally produced:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table really_want as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select * from want&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by id&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; having test_date eq min(test_date)&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Aug 2012 21:31:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/question-about-specific-selection/m-p/93756#M26590</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-08-14T21:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: question about specific selection</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/question-about-specific-selection/m-p/93757#M26591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What about:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select e.id, count(*) as exercises_6monthPrev_cnt&lt;/P&gt;&lt;P&gt;&amp;nbsp; from &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (select * from test where 2&amp;lt;=score&amp;lt;=4 group by id having min(test_date)=test_date) t&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , exercise e&lt;/P&gt;&lt;P&gt;&amp;nbsp; where t.id=e.id and t.test_date &amp;gt;= intnx('month',e.exercise_date,6,'s')&lt;/P&gt;&lt;P&gt;&amp;nbsp; group by e.id&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Aug 2012 21:36:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/question-about-specific-selection/m-p/93757#M26591</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-08-14T21:36:44Z</dc:date>
    </item>
    <item>
      <title>Re: question about specific selection</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/question-about-specific-selection/m-p/93758#M26592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use PROC MEANS with the min stat to get the earliest date with 2&amp;lt;=socre&amp;lt;=4 for each id.&amp;nbsp; Not presorting required:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc means data=test (where=(2&amp;lt;=score&amp;lt;=4)) min noprint nway;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; class id;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; var_test_date;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; output out=tdates (keep=id test_date)&amp;nbsp; min=;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;** But for most non-hash solutions, the exercise data should be sorted to interleave with the TDATES dataset above: **;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=exercise&amp;nbsp; out=exer_srt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by id exercise_date;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;** Note: the "set&amp;nbsp;&amp;nbsp; xxx yyy" with a BY statement always has the XXX data precede the YYY data for a given BY value.**:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (keep=id test_date cut_date n_dates);&lt;BR /&gt;&amp;nbsp; do until (last.id);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set tdates&amp;nbsp; (in=int)&amp;nbsp; exer_srt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by id;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if first.id then n_dates=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if int then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cut_date=intnx('month',test_date,-6,'end');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tdate=test_date;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if exercise_date &amp;lt;= cut_date then n_dates=n_dates+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if cut_date^=. then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; test_date=tdate;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format cut_date date9.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 00:42:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/question-about-specific-selection/m-p/93758#M26592</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2012-08-15T00:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: question about specific selection</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/question-about-specific-selection/m-p/93759#M26593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, thanks very much, Arthur, Patrick and Mkeintz, for your prompt response and help!&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 16:40:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/question-about-specific-selection/m-p/93759#M26593</guid>
      <dc:creator>user1</dc:creator>
      <dc:date>2012-08-15T16:40:59Z</dc:date>
    </item>
  </channel>
</rss>

