<?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: Need SAS code for selecting rows based on condition in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Need-SAS-code-for-selecting-rows-based-on-condition/m-p/570138#M11926</link>
    <description>&lt;P&gt;Thanks a lot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works . I missed a line of a code so I was facing the error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I corrected it and it is working as per my expectations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;once again Thanks. Really appreciate the efforts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Priyanka&lt;/P&gt;</description>
    <pubDate>Mon, 01 Jul 2019 05:25:51 GMT</pubDate>
    <dc:creator>priyanka14</dc:creator>
    <dc:date>2019-07-01T05:25:51Z</dc:date>
    <item>
      <title>Need SAS code for selecting rows based on condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-SAS-code-for-selecting-rows-based-on-condition/m-p/569028#M11754</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I need help on SAS EG Code for my below problem. I am usins SAS EG version 7.1&lt;/P&gt;&lt;P&gt;I have a dataset which includes few columns. The excel file is attached with the mail.&lt;/P&gt;&lt;P&gt;I have mentioned the input and output sheet ( the way i want my output).&lt;/P&gt;&lt;P&gt;My problem statment :&lt;/P&gt;&lt;P&gt;in input sheet, first i want to sort the month column by descending order for each category and then i have to first find out the number less than 3 in "used" column for each variable in "category" column . Then i have to select&amp;nbsp; all the&amp;nbsp;rows which&amp;nbsp;are below that number ( less than 3 , ex 2) . This i need to do for each variable in "category" column.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got stuck with this almost from 2 days and not even able to proceed further.&lt;/P&gt;&lt;P&gt;Your quick support will highly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Priyanka&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 09:16:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-SAS-code-for-selecting-rows-based-on-condition/m-p/569028#M11754</guid>
      <dc:creator>priyanka14</dc:creator>
      <dc:date>2019-06-26T09:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: Need SAS code for selecting rows based on condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-SAS-code-for-selecting-rows-based-on-condition/m-p/569105#M11759</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*   DUMMY DATASET   */
DATA WORK.HAVE;
FORMAT 	 Category $1. 	Month MonYY5.	used 8.	new_used 8.	variety $3.;
INFORMAT Category $1. 	Month MonYY5.	used 8.	new_used 8.	variety $3.;
INPUT    Category	    Month	        used	new_used	variety;
INFILE DATALINES DLM='|' DSD;
DATALINES;
A|Jan-18|6|20|MI
B|Jan-18|8|20|MI
C|Jan-18|8|20|AZ
D|Jan-18|8|20|AZ
A|Feb-18|5|20|AP
B|Feb-18|12|20|AP
C|Feb-18|23|20|MI
D|Feb-18|23|20|MI
A|Mar-18|5|20|NOK
B|Mar-18|3|20|NOK
C|Mar-18|3|20|AP
D|Mar-18|3|20|AP
A|Apr-18|10|20|AC
B|Apr-18|18|20|AC
C|Apr-18|18|20|NOK
D|Apr-18|18|20|NOK
A|May-18|9|20|PS
B|May-18|5|20|PS
C|May-18|5|20|AC
D|May-18|5|20|AC
A|Jun-18|8|20|CD
B|Jun-18|6|20|CD
C|Jun-18|6|20|PS
D|Jun-18|6|20|PS
A|Jul-18|3|20|MI
B|Jul-18|7|20|MI
C|Jul-18|7|20|CD
A|Aug-18|2|2|EH
B|Aug-18|2|2|EH
C|Aug-18|2|2|MI
D|Aug-18|2|2|CD
A|Sep-18|12|20|EF
B|Sep-18|12|20|EF
C|Sep-18|12|20|EH
D|Sep-18|7|20|MI
A|Oct-18|12|20|AZ
C|Oct-18|10|20|EF
;


PROC SORT DATA=WORK.HAVE; BY Category DESCENDING Month; RUN;


/*   ID MAX DATE per Category where Used value LT 3  */
PROC SQL;
CREATE TABLE WORK.WANT_A	AS
	SELECT
		  Category
		, MAX(Month)	AS MAXMONTH FORMAT=MONYY5.

	FROM WORK.HAVE
	WHERE Used &amp;lt; 3
	GROUP BY Category
	ORDER BY Category, MAXMONTH;
QUIT;


/*   JOIN MAX DATE TABLE BACK TO FULL TABLE */
PROC SQL;
CREATE TABLE WORK.WANT_Final	AS
	SELECT
		a.*

	FROM		WORK.Have		AS a
	LEFT JOIN 	WORK.WANT_A		AS b	ON a.Category=b.Category
	WHERE a.MONTH &amp;lt; b.MAXMONTH;
QUIT;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Jun 2019 14:11:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-SAS-code-for-selecting-rows-based-on-condition/m-p/569105#M11759</guid>
      <dc:creator>tsap</dc:creator>
      <dc:date>2019-06-26T14:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need SAS code for selecting rows based on condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-SAS-code-for-selecting-rows-based-on-condition/m-p/569399#M11799</link>
      <description>&lt;P&gt;Thanks for the respone.&lt;/P&gt;&lt;P&gt;Using this code, it is only removing the rows where "Used" column is less than 3 . But my requirement is also to remove all those rows which is above less than 3 Category wise. I have also attached the ouput sheet , the way i want to have my output data.&lt;/P&gt;&lt;P&gt;I&amp;nbsp;am attaching&amp;nbsp;the snap also to make it more clear&amp;nbsp;. The yellow highlighted rows , i want to remove and rest i want as my output. The output should look&amp;nbsp;like the same (ex category A, Month from Jul18-Jan18,used column 3-6 ....like that). Category should not&amp;nbsp;be mixed. out put : first non-highlighted rows of A, then B non highlighted rows like that i want in my output.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Want to remove the highlighted rows also" style="width: 295px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30594i99C2CE6AF1014EA0/image-dimensions/295x299?v=v2" width="295" height="299" role="button" title="SAS_Query.PNG" alt="Want to remove the highlighted rows also" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Want to remove the highlighted rows also&lt;/span&gt;&lt;/span&gt;I hope this will help you to understand extactly what kind of output i am looking for.I guess may be we need to put some loop .&lt;/P&gt;&lt;P&gt;Thanks in advance. Looking for the code .&lt;/P&gt;&lt;P&gt;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 12:42:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-SAS-code-for-selecting-rows-based-on-condition/m-p/569399#M11799</guid>
      <dc:creator>priyanka14</dc:creator>
      <dc:date>2019-06-27T12:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: Need SAS code for selecting rows based on condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-SAS-code-for-selecting-rows-based-on-condition/m-p/569443#M11818</link>
      <description>&lt;P&gt;I'm not sure what the issue is with the prior solution. The dataset output in the end matches the exact requirements you just stated in your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="snapshot_dummydata.PNG" style="width: 416px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30597i8FCD525F24689C0D/image-size/large?v=v2&amp;amp;px=999" role="button" title="snapshot_dummydata.PNG" alt="snapshot_dummydata.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you&amp;nbsp;can clearly see, for Category A the output dataset has from Jul18th to Jan18. So based on your criteria provided, the code is performing as you need it to perform.All of the 'non-highlighted rows' in your screenshot are the observations on my screen shot. And I just ran my logic to generate this.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 14:25:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-SAS-code-for-selecting-rows-based-on-condition/m-p/569443#M11818</guid>
      <dc:creator>tsap</dc:creator>
      <dc:date>2019-06-27T14:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Need SAS code for selecting rows based on condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-SAS-code-for-selecting-rows-based-on-condition/m-p/570138#M11926</link>
      <description>&lt;P&gt;Thanks a lot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works . I missed a line of a code so I was facing the error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I corrected it and it is working as per my expectations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;once again Thanks. Really appreciate the efforts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Priyanka&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2019 05:25:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-SAS-code-for-selecting-rows-based-on-condition/m-p/570138#M11926</guid>
      <dc:creator>priyanka14</dc:creator>
      <dc:date>2019-07-01T05:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: Need SAS code for selecting rows based on condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-SAS-code-for-selecting-rows-based-on-condition/m-p/570263#M11933</link>
      <description>&lt;P&gt;You're welcome. Glad I could help.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2019 14:14:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-SAS-code-for-selecting-rows-based-on-condition/m-p/570263#M11933</guid>
      <dc:creator>tsap</dc:creator>
      <dc:date>2019-07-01T14:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: Need SAS code for selecting rows based on condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-SAS-code-for-selecting-rows-based-on-condition/m-p/572137#M12280</link>
      <description>Hello,&lt;BR /&gt;With the addition of whatever I asked earlier. Now suppose for each category , there are 4 different sub-groups.like After this category column, I have another column let say group and for category A- there r 4 grps (G1,G2,G3,G4) and same with other Categories also( G1,G2,G3,G4 ) .&lt;BR /&gt;Now My requirement is same like earlier one.ie.want to sort the month column by descending order for each category with its group level and then i have to first find out the number less than 3 in "used" column for each variable in "category" along with group level column . Then i have to select all the rows which are below that number ( less than 3 , ex 2) . This i need to do for each variable in "category" and its group level.&lt;BR /&gt;&lt;BR /&gt;I tried to create a new column by concatenate the category and group column and then follow the same code provided by you .&lt;BR /&gt;But it's not working in this case. Can you suggest me what else I can do.i tried for macro also but failed</description>
      <pubDate>Tue, 09 Jul 2019 16:08:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-SAS-code-for-selecting-rows-based-on-condition/m-p/572137#M12280</guid>
      <dc:creator>priyanka14</dc:creator>
      <dc:date>2019-07-09T16:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need SAS code for selecting rows based on condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-SAS-code-for-selecting-rows-based-on-condition/m-p/572611#M12354</link>
      <description>&lt;P&gt;Looking for the solution if anyone can help me out&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 05:14:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-SAS-code-for-selecting-rows-based-on-condition/m-p/572611#M12354</guid>
      <dc:creator>priyanka14</dc:creator>
      <dc:date>2019-07-11T05:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: Need SAS code for selecting rows based on condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-SAS-code-for-selecting-rows-based-on-condition/m-p/573790#M12575</link>
      <description>&lt;P&gt;Hello ,&lt;/P&gt;&lt;P&gt;I am in urgent need of a SAS EG code. I need the same thing which I asked you earlier but the only thing is like now I added one more category. I have attached the excel sheet also which has input and the output which I required.&lt;/P&gt;&lt;P&gt;First of all , I need to sort the category, category2,Month in descending order . For each category , there are four category2 level ( 1,2,3,4).&lt;/P&gt;&lt;P&gt;&amp;nbsp;So My requirement is that for each category and its each category2 level , first I need check used column . and in used column , I have to find&amp;nbsp;out the number greater than or equal to 3 and&amp;nbsp;&amp;nbsp;need to select only the continuous rows. Suppose with Category 'A' having Category2 as '4', in "used"column the data are 12,12,2,3,8,10 , then I need to select all rows only from used column data 3 ( 3,8,10)&lt;/P&gt;&lt;P&gt;Same thing I have highlighted in"&amp;nbsp;sorted&amp;nbsp;data" that whatever the data is required in output sheet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and if in some day I have one more category after category2 like Category3 and again the I need the same kind of output looking this added category also. then can you suggest me where I need to make changes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this attached sheet , the input sheet and then after sorting the input sheet by category,category2 and months and then the output sheet ( the way I want my result).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2019 10:11:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-SAS-code-for-selecting-rows-based-on-condition/m-p/573790#M12575</guid>
      <dc:creator>priyanka14</dc:creator>
      <dc:date>2019-07-16T10:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: Need SAS code for selecting rows based on condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-SAS-code-for-selecting-rows-based-on-condition/m-p/575494#M12871</link>
      <description>Show the code you tried.</description>
      <pubDate>Mon, 22 Jul 2019 17:32:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-SAS-code-for-selecting-rows-based-on-condition/m-p/575494#M12871</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-22T17:32:09Z</dc:date>
    </item>
  </channel>
</rss>

