<?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 use First.  To get the following output. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-First-To-get-the-following-output/m-p/465274#M118671</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212167"&gt;@Bhavanaa44&lt;/a&gt;&amp;nbsp; Ok, I am assuming the interviewer perhaps wanted to test your knowledge on by group processing in a datastep and that's the same he/she has given you. Apparently, the interviewer wants you to apply first and last automatic variables on the sample and output the first. var for the records.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I suppose the interviewer wants to pick the first score of each of the names that happens to the grouping variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like the following is what perhaps the interviewer was seeking&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;

set have;

by name score;

if first.score;

run;
after sorting the input(have) by name and score&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 26 May 2018 17:19:21 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-05-26T17:19:21Z</dc:date>
    <item>
      <title>How to use First.  To get the following output.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-First-To-get-the-following-output/m-p/465271#M118668</link>
      <description>Obs. Number name score N&lt;BR /&gt;1. 1 David. 54. 1&lt;BR /&gt;2. 1. David. 75 2&lt;BR /&gt;3. 2. Sam. 24. 1&lt;BR /&gt;4. 2. Ram. 35. 1</description>
      <pubDate>Sat, 26 May 2018 16:46:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-First-To-get-the-following-output/m-p/465271#M118668</guid>
      <dc:creator>Bhavanaa44</dc:creator>
      <dc:date>2018-05-26T16:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to use First.  To get the following output.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-First-To-get-the-following-output/m-p/465272#M118669</link>
      <description>&lt;P&gt;Hi, You wrote-"&lt;/P&gt;&lt;P&gt;How to use First. To get the following output."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. The following output from where( which input data sample)?&lt;/P&gt;&lt;P&gt;2. What do you want to accomplish?&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 26 May 2018 16:49:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-First-To-get-the-following-output/m-p/465272#M118669</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-26T16:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to use First.  To get the following output.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-First-To-get-the-following-output/m-p/465273#M118670</link>
      <description>I got this question in interview.&lt;BR /&gt;They have just given me the output and told me to write program for it.</description>
      <pubDate>Sat, 26 May 2018 16:53:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-First-To-get-the-following-output/m-p/465273#M118670</guid>
      <dc:creator>Bhavanaa44</dc:creator>
      <dc:date>2018-05-26T16:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to use First.  To get the following output.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-First-To-get-the-following-output/m-p/465274#M118671</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212167"&gt;@Bhavanaa44&lt;/a&gt;&amp;nbsp; Ok, I am assuming the interviewer perhaps wanted to test your knowledge on by group processing in a datastep and that's the same he/she has given you. Apparently, the interviewer wants you to apply first and last automatic variables on the sample and output the first. var for the records.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I suppose the interviewer wants to pick the first score of each of the names that happens to the grouping variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like the following is what perhaps the interviewer was seeking&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;

set have;

by name score;

if first.score;

run;
after sorting the input(have) by name and score&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 May 2018 17:19:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-First-To-get-the-following-output/m-p/465274#M118671</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-26T17:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to use First.  To get the following output.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-First-To-get-the-following-output/m-p/465275#M118672</link>
      <description>&lt;P&gt;If you are looking at DW/BI/Analytics careers using SAS, I suggest you to invest in some sas books by authors ron cody, art carpenter to speed up your learning&lt;/P&gt;</description>
      <pubDate>Sat, 26 May 2018 17:21:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-First-To-get-the-following-output/m-p/465275#M118672</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-26T17:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to use First.  To get the following output.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-First-To-get-the-following-output/m-p/465293#M118676</link>
      <description>&lt;P&gt;It looks like you want the first two records for each by group with 2 or more records.&amp;nbsp; And the first record for any single-record by-group.&amp;nbsp; It also looks like you have to produce N=1, N=2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  by name;
  if first.name then N=1;&lt;BR /&gt;  else N+1;
&amp;nbsp; if N&amp;lt;=2;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 26 May 2018 23:47:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-First-To-get-the-following-output/m-p/465293#M118676</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-05-26T23:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to use First.  To get the following output.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-First-To-get-the-following-output/m-p/465304#M118678</link>
      <description>I will run this code and see if the same output is coming or not.&lt;BR /&gt;&lt;BR /&gt;One more thing is there any way to install SAS in windows 10. As I have in VMware and it is very slow</description>
      <pubDate>Sun, 27 May 2018 03:30:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-First-To-get-the-following-output/m-p/465304#M118678</guid>
      <dc:creator>Bhavanaa44</dc:creator>
      <dc:date>2018-05-27T03:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to use First.  To get the following output.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-First-To-get-the-following-output/m-p/465328#M118684</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212167"&gt;@Bhavanaa44&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I will run this code and see if the same output is coming or not.&lt;BR /&gt;&lt;BR /&gt;One more thing is there any way to install SAS in windows 10. As I have in VMware and it is very slow&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, that should work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The best place to get answers to such questions is the SAS Install Center.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/documentation/installcenter/" target="_blank"&gt;https://support.sas.com/documentation/installcenter/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/en/documentation/system-requirements.html" target="_blank"&gt;https://support.sas.com/en/documentation/system-requirements.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/installcenter/en/ikfdtnwinsr/67228/PDF/default/sreq.pdf&amp;nbsp;" target="_blank"&gt;http://support.sas.com/documentation/installcenter/en/ikfdtnwinsr/67228/PDF/default/sreq.pdf&amp;nbsp;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 27 May 2018 11:17:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-First-To-get-the-following-output/m-p/465328#M118684</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-05-27T11:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to use First.  To get the following output.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-First-To-get-the-following-output/m-p/466382#M118996</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have run the code but output didn't come as desired.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Question asked :&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Obs. Number name score N&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. 1 David. 54. 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. 1. David. 75 2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. 2. Sam. 24. 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4. 2. Ram. 35. 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please find my code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data x;&lt;BR /&gt;input number name $ score;&lt;BR /&gt;cards;&lt;BR /&gt;1 David 75&lt;BR /&gt;2 Sam 24&lt;BR /&gt;2 Ram 35&lt;BR /&gt;1 David 54&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data=x;&lt;BR /&gt;by name score;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set x;&lt;BR /&gt;by name score;&lt;BR /&gt;if first.name then N=1; else N+1;&lt;BR /&gt;if N&amp;lt;=2;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output after running above code:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Obs. Number name score N&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. 1 David&amp;nbsp; &amp;nbsp;54&amp;nbsp; 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. 1. David&amp;nbsp; 75 2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. 2. Ram&amp;nbsp;&amp;nbsp; 35&amp;nbsp;1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4. 2. Sam&amp;nbsp; &amp;nbsp;24 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2018 10:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-First-To-get-the-following-output/m-p/466382#M118996</guid>
      <dc:creator>Bhavanaa44</dc:creator>
      <dc:date>2018-05-31T10:18:15Z</dc:date>
    </item>
  </channel>
</rss>

