<?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 Question about (keep=) in DATA statement in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Question-about-keep-in-DATA-statement/m-p/528663#M5473</link>
    <description>&lt;P&gt;Hello !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try to solve some quizzes. Considering the following data set :&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="Image15.jpg" style="width: 509px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26390iBBA1E2B42E4934FE/image-size/large?v=v2&amp;amp;px=999" role="button" title="Image15.jpg" alt="Image15.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;if you submit the following code :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data emp(drop=Manager_EMP_ID Salary);
     set emp (keep=Manager_EMP_ID Employee_ID Salary);
     if Manager_Emp_ID=101 and Salary &amp;gt;45000;
     Age = yrdif(DOB,'05Feb2017'd,'Actual'd);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why&amp;nbsp;&lt;SPAN&gt;Employee_ID, Age should be the variables appearing in the emp dataset ? The (keep=) on the lane 2 shouldn't ignore DOB while creating the PDV and so creating an error when reaching the following lane ?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Age = yrdif(DOB,'05Feb2017'd,'Actual'd);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Jan 2019 01:32:57 GMT</pubDate>
    <dc:creator>Masande</dc:creator>
    <dc:date>2019-01-21T01:32:57Z</dc:date>
    <item>
      <title>Question about (keep=) in DATA statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Question-about-keep-in-DATA-statement/m-p/528663#M5473</link>
      <description>&lt;P&gt;Hello !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try to solve some quizzes. Considering the following data set :&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="Image15.jpg" style="width: 509px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26390iBBA1E2B42E4934FE/image-size/large?v=v2&amp;amp;px=999" role="button" title="Image15.jpg" alt="Image15.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;if you submit the following code :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data emp(drop=Manager_EMP_ID Salary);
     set emp (keep=Manager_EMP_ID Employee_ID Salary);
     if Manager_Emp_ID=101 and Salary &amp;gt;45000;
     Age = yrdif(DOB,'05Feb2017'd,'Actual'd);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why&amp;nbsp;&lt;SPAN&gt;Employee_ID, Age should be the variables appearing in the emp dataset ? The (keep=) on the lane 2 shouldn't ignore DOB while creating the PDV and so creating an error when reaching the following lane ?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Age = yrdif(DOB,'05Feb2017'd,'Actual'd);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 01:32:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Question-about-keep-in-DATA-statement/m-p/528663#M5473</guid>
      <dc:creator>Masande</dc:creator>
      <dc:date>2019-01-21T01:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: Question about (keep=) in DATA statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Question-about-keep-in-DATA-statement/m-p/528665#M5474</link>
      <description>&lt;P&gt;'Actual'd isn't whatever you think it is. What are you expecting from that portion of the code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is no 'actual', I suspect you want the TODAY() function instead perhaps?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/252475"&gt;@Masande&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I try to solve some quizzes. Considering the following data set :&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="Image15.jpg" style="width: 509px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26390iBBA1E2B42E4934FE/image-size/large?v=v2&amp;amp;px=999" role="button" title="Image15.jpg" alt="Image15.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;if you submit the following code :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data emp(drop=Manager_EMP_ID Salary);
     set emp (keep=Manager_EMP_ID Employee_ID Salary);
     if Manager_Emp_ID=101 and Salary &amp;gt;45000;
     Age = yrdif(DOB,'05Feb2017'd,'Actual'd);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why&amp;nbsp;&lt;SPAN&gt;Employee_ID, Age should be the variables appearing in the emp dataset ? The (keep=) on the lane 2 shouldn't ignore DOB while creating the PDV and so creating an error when reaching the following lane ?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Age = yrdif(DOB,'05Feb2017'd,'Actual'd);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 01:44:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Question-about-keep-in-DATA-statement/m-p/528665#M5474</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-21T01:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: Question about (keep=) in DATA statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Question-about-keep-in-DATA-statement/m-p/528666#M5475</link>
      <description>&lt;P&gt;I simply copied the question from the quiz without any modification. I hadn't even noticed the 'Actual'd thing. I know what Actual does in yrdiff (alias for "act/act") but never met the "+d" version.&lt;BR /&gt;&lt;BR /&gt;So my first question remains, and I can add : "What's "Actual"d ?"&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 02:01:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Question-about-keep-in-DATA-statement/m-p/528666#M5475</guid>
      <dc:creator>Masande</dc:creator>
      <dc:date>2019-01-21T02:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: Question about (keep=) in DATA statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Question-about-keep-in-DATA-statement/m-p/528667#M5476</link>
      <description>&lt;P&gt;The INTCK formula is wrong. Fix that and you'll likely solve your issues.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which quiz are you using? If it's a SAS quiz, it's a good idea to report errors like this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have no idea what 'actual'd is or what it's supposed to do in this context. It's wrong.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The reason you're getting this type of behaviour is this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data OUTPUT;
set OUTPUT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When you you use the same name as the input and output set you often get unexpected behaviour when your code errors out, which is what is happening in this case. Fix the errors in INTCK() FIRST and then see if you still have the same issues.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The INTCK() documentation is here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p1md4mx2crzfaqn14va8kt7qvfhr.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p1md4mx2crzfaqn14va8kt7qvfhr.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/252475"&gt;@Masande&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;STRONG&gt;I simply copied the question from the quiz without any modification.&lt;/STRONG&gt; I hadn't even noticed the 'Actual'd thing. I know what Actual does in yrdiff (alias for "act/act") but never met the "+d" version.&lt;BR /&gt;&lt;BR /&gt;So my first question remains, and I can add : "What's "Actual"d ?"&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 02:16:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Question-about-keep-in-DATA-statement/m-p/528667#M5476</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-21T02:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: Question about (keep=) in DATA statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Question-about-keep-in-DATA-statement/m-p/528671#M5477</link>
      <description>I found the quizz here : &lt;A href="https://www.analyticsvidhya.com/blog/2017/02/40-must-know-questions-on-base-sas-for-analysts-data-scientists-out-there-skilltest-solution/" target="_blank"&gt;https://www.analyticsvidhya.com/blog/2017/02/40-must-know-questions-on-base-sas-for-analysts-data-scientists-out-there-skilltest-solution/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;The question is the n°17.</description>
      <pubDate>Mon, 21 Jan 2019 02:39:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Question-about-keep-in-DATA-statement/m-p/528671#M5477</guid>
      <dc:creator>Masande</dc:creator>
      <dc:date>2019-01-21T02:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: Question about (keep=) in DATA statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Question-about-keep-in-DATA-statement/m-p/528672#M5478</link>
      <description>&lt;P&gt;Ah...well, it's wrong. Whomever wrote that doesn't seem to understand the INTCK() function at all.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 03:01:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Question-about-keep-in-DATA-statement/m-p/528672#M5478</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-21T03:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: Question about (keep=) in DATA statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Question-about-keep-in-DATA-statement/m-p/528675#M5479</link>
      <description>&lt;P&gt;Not sure why I had it in my head that INTCK was being used, YRDIF doesn't have the ACTUAL parameter so that needs to be fixed. It will still return an error because DOB is not in the input data set. Note that the KEEP on the SET statement does not include DOB.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; set emp (keep=Manager_EMP_ID Employee_ID Salary);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then if you look at the data set option closely, it's a DROP. So you know have:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;manager_emp_id employee_id salary and AGE/DOB (all missing), and then you drop more variables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data emp(drop=Manager_EMP_ID Salary);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So in the end, you end up with:&lt;/P&gt;
&lt;P&gt;employee_id, age and DOB, with only Employee_ID filled in.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a really, really bad example IMO. You should try finding a different method of studying, I recommend the Little SAS book which has been edited and used by hundred if not thousands of SAS programmers.&amp;nbsp;&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;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2019-01-20 at 8.35.42 PM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26391iD1A094E325932977/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2019-01-20 at 8.35.42 PM.png" alt="Screen Shot 2019-01-20 at 8.35.42 PM.png" /&gt;&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 03:37:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Question-about-keep-in-DATA-statement/m-p/528675#M5479</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-21T03:37:12Z</dc:date>
    </item>
  </channel>
</rss>

