<?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 count every positive result for each student and each exam apart? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-count-every-positive-result-for-each-student-and-each/m-p/583146#M13925</link>
    <description>&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;it works!!! Why was I thinking so hard?! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If you care to explain this to me:&lt;/P&gt;&lt;P&gt;-what you did in datalines and why&lt;/P&gt;&lt;P&gt;-and what this peace of code means/does:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function"&gt;count&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;GRADE_POINTS&lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I Will accept your reply as solution to my question!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Aug 2019 12:31:11 GMT</pubDate>
    <dc:creator>SAS_Question</dc:creator>
    <dc:date>2019-08-22T12:31:11Z</dc:date>
    <item>
      <title>How to count every positive result for each student and each exam apart?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-count-every-positive-result-for-each-student-and-each/m-p/583111#M13920</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this example data set (see xlsx file attached) in sheet "have". and want to get the count like in sheet "want".&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone please help me with this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this within a sas data set with "if FIRST.STUDENT_ID and FIRST.COURSE_ID and FIRST.Exam_Date then count = 1; etc.&lt;/P&gt;&lt;P&gt;But&amp;nbsp; I dont seem to get it right with this option in SAS?... &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance all!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 09:35:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-count-every-positive-result-for-each-student-and-each/m-p/583111#M13920</guid>
      <dc:creator>SAS_Question</dc:creator>
      <dc:date>2019-08-22T09:35:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to count every positive result for each student and each exam apart?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-count-every-positive-result-for-each-student-and-each/m-p/583113#M13921</link>
      <description>&lt;P&gt;Please post data in usable form: a data step using datalines and explain the logic you want to apply to that data. Then show what you expect as result, again as data step with datalines or as table in the post.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 10:19:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-count-every-positive-result-for-each-student-and-each/m-p/583113#M13921</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-08-22T10:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to count every positive result for each student and each exam apart?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-count-every-positive-result-for-each-student-and-each/m-p/583115#M13922</link>
      <description>&lt;P&gt;Hi Andreas,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry I don't use datalines, and never had, as I use SAS EG here. Not Base SAS. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please just download the attachment and use this code like I do to import the data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let path=P:\Example _data.xlsx;  /* replace with your path and file name! */

proc import datafile="&amp;amp;path"
	out=RES dbms=xlsx replace;
	getnames=yes;
run;

proc sort data=res out=test;
	by Student_ID COURSE_ID exam_date;
run;

data result;
set test;
by Student_ID COURSE_ID exam_date;
count=0;

if FIRST.Student_ID then do;
	if FIRST.COURSE_ID then do;
		if FIRST.exam_date then Count=1;
	end;
end;

count+1;

if LAST.Student_ID then do;
	if LAST.Course_ID then do;
		if LAST.exam_date then output;
	end;
end;
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;So what I want (as you can see in the xlsx file on sheet "want" is:&amp;nbsp;&lt;BR /&gt;See sceenshot:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="WANT.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/31946iF9715D04E780FC25/image-size/large?v=v2&amp;amp;px=999" role="button" title="WANT.PNG" alt="WANT.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this is okay for you to test the data. If you still want datalines, please let me know!&amp;nbsp;&lt;/P&gt;&lt;P&gt;TiA.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;EDIT:&amp;nbsp;&lt;BR /&gt;is this a good datalines set for this data?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
infile datalines;
input STUDENT_ID	COURSE_ID	GRADE_POINTS	EXAM_DATE;

   datalines;
1111	1000T	6	2017-07-05
1111	2000T	7	2017-10-31
2222	1000T	8	2017-10-30
2222	2000T	8	2017-01-10
2222	3000T	8	2017-01-05
2222	4000T	9	2017-03-22
2222	5000T	9	2017-03-20
2222	6000T	8	2017-05-29
2222	7000T	9	2017-06-06
2222	8000T	7	2017-05-31
3333	4000T	9	2015-10-26
4444	1000T	7,5	2015-10-09
4444	2000T	8	2015-10-06
4444	3000T	7	2016-11-23
4444	4000T	7	2015-11-19
4444	5000T	7,5	2015-12-14
4444	6000T	6	2017-03-02
4444	7000T	7	2016-06-10
4444	8000T	6	2016-04-14
4444	8000T	8	2016-05-14

;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Aug 2019 11:08:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-count-every-positive-result-for-each-student-and-each/m-p/583115#M13922</guid>
      <dc:creator>SAS_Question</dc:creator>
      <dc:date>2019-08-22T11:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to count every positive result for each student and each exam apart?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-count-every-positive-result-for-each-student-and-each/m-p/583135#M13923</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data test;
infile datalines expandtabs;
input (STUDENT_ID	COURSE_ID) ($)	GRADE_POINTS	EXAM_DATE :yymmdd10.;
format 	EXAM_DATE yymmdd10.;
   datalines;
1111	1000T	6	2017-07-05
1111	2000T	7	2017-10-31
2222	1000T	8	2017-10-30
2222	2000T	8	2017-01-10
2222	3000T	8	2017-01-05
2222	4000T	9	2017-03-22
2222	5000T	9	2017-03-20
2222	6000T	8	2017-05-29
2222	7000T	9	2017-06-06
2222	8000T	7	2017-05-31
3333	4000T	9	2015-10-26
4444	1000T	7.5	2015-10-09
4444	2000T	8	2015-10-06
4444	3000T	7	2016-11-23
4444	4000T	7	2015-11-19
4444	5000T	7.5	2015-12-14
4444	6000T	6	2017-03-02
4444	7000T	7	2016-06-10
4444	8000T	6	2016-04-14
4444	8000T	8	2016-05-14
;
run;


data want;
 set test;
 by  STUDENT_ID	COURSE_ID;
 if first.COURSE_ID then count=.;
 count+GRADE_POINTS&amp;gt;0;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Aug 2019 11:50:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-count-every-positive-result-for-each-student-and-each/m-p/583135#M13923</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-22T11:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to count every positive result for each student and each exam apart?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-count-every-positive-result-for-each-student-and-each/m-p/583146#M13925</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;it works!!! Why was I thinking so hard?! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If you care to explain this to me:&lt;/P&gt;&lt;P&gt;-what you did in datalines and why&lt;/P&gt;&lt;P&gt;-and what this peace of code means/does:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function"&gt;count&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;GRADE_POINTS&lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I Will accept your reply as solution to my question!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 12:31:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-count-every-positive-result-for-each-student-and-each/m-p/583146#M13925</guid>
      <dc:creator>SAS_Question</dc:creator>
      <dc:date>2019-08-22T12:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to count every positive result for each student and each exam apart?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-count-every-positive-result-for-each-student-and-each/m-p/583150#M13926</link>
      <description>&lt;PRE class="  language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function"&gt;count&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;GRADE_POINTS&lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is a boolean expression i.e&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when true=1, so&amp;nbsp; count+(1)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when false=0,so&amp;nbsp; count+(0)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And the value is reset to missing when we process records of new courseid making it distinct counts of couseid in sequence when &lt;EM&gt;true&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Well , WRT datalines, our request like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp; pointed for members to post in the form that we don't have to type line by line in creating a dataset and then work on it. It can be time consuming. So we thank you for that. All I did was formatted with the right type and date formats to read the datalines correctly. No Biggie.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So going forward, help us with the following 3(all in plain text)&lt;/P&gt;
&lt;P&gt;1. Sample of HAVE dataset&lt;/P&gt;
&lt;P&gt;2. Sample of WANT dataset&lt;/P&gt;
&lt;P&gt;3. A brief explanation of logic relating to the WANT dataset i.e how to derive it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course with the above 3, leave the technical part to us&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 12:47:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-count-every-positive-result-for-each-student-and-each/m-p/583150#M13926</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-22T12:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to count every positive result for each student and each exam apart?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-count-every-positive-result-for-each-student-and-each/m-p/583155#M13928</link>
      <description>&lt;P&gt;Thanks guys!&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;thank you for the explanation of your code! Very neat! I like that! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And will keep the posting rules in mind for my future questions here! Thanks again all!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 12:54:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-count-every-positive-result-for-each-student-and-each/m-p/583155#M13928</guid>
      <dc:creator>SAS_Question</dc:creator>
      <dc:date>2019-08-22T12:54:01Z</dc:date>
    </item>
  </channel>
</rss>

