<?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: KEEP more then 2 variables in &amp;quot;IF_N_ = 1 THEN SET ...&amp;quot; in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/KEEP-more-then-2-variables-in-quot-IF-N-1-THEN-SET-quot/m-p/99205#M27905</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SAS doesn't limit the variables you can read in, so the problem lies elsewhere.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume that you have already checked the data set CASE to make sure that the values you bring in are not missing to begin with.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the problem likely lies in CONTROL.&amp;nbsp; If that data set also contains the additional variables (and has missing values for them), you would get the results you are observing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 03 Aug 2013 22:12:01 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2013-08-03T22:12:01Z</dc:date>
    <item>
      <title>KEEP more then 2 variables in "IF_N_ = 1 THEN SET ..."</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/KEEP-more-then-2-variables-in-quot-IF-N-1-THEN-SET-quot/m-p/99204#M27904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When running the following SAS syntax, I found that I can keep maximum two variables (e.g., x1, x2) using "KEEP" after IF .... THEN.... if I keep three or more variables, only two variables have values and other variables are with missing values. Could anyone please tell me how to keep three or more variables?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA case_control;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF_N_ = 1 THEN SET case (keep = x1 x2 RENAME (x1=height_case x2 = weight_case));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET control;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; diff1 = height_case - height;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; diff2 = weight_case - weight;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Aug 2013 20:52:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/KEEP-more-then-2-variables-in-quot-IF-N-1-THEN-SET-quot/m-p/99204#M27904</guid>
      <dc:creator>ZC</dc:creator>
      <dc:date>2013-08-03T20:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: KEEP more then 2 variables in "IF_N_ = 1 THEN SET ..."</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/KEEP-more-then-2-variables-in-quot-IF-N-1-THEN-SET-quot/m-p/99205#M27905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SAS doesn't limit the variables you can read in, so the problem lies elsewhere.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume that you have already checked the data set CASE to make sure that the values you bring in are not missing to begin with.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the problem likely lies in CONTROL.&amp;nbsp; If that data set also contains the additional variables (and has missing values for them), you would get the results you are observing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Aug 2013 22:12:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/KEEP-more-then-2-variables-in-quot-IF-N-1-THEN-SET-quot/m-p/99205#M27905</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-08-03T22:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: KEEP more then 2 variables in "IF_N_ = 1 THEN SET ..."</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/KEEP-more-then-2-variables-in-quot-IF-N-1-THEN-SET-quot/m-p/99206#M27906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It could be that the control dataset overwrites some of your variables. Your example, once fixed for the typos (space between IF and _N_ and = after RENAME), works just fine, even with and extra variable in the case dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data case;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;x1=1; x2=2; x3=3;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data control;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;input height weight;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;10 100&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;20 200&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;30 300&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DATA case_control;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF _N_ = 1 THEN SET case (keep = x1 x2 x3 RENAME=(x1=height_case x2 = weight_case x3=test));&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET control;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; diff1 = height_case - height;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; diff2 = weight_case - weight;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;RUN;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc print; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Aug 2013 22:12:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/KEEP-more-then-2-variables-in-quot-IF-N-1-THEN-SET-quot/m-p/99206#M27906</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-08-03T22:12:49Z</dc:date>
    </item>
  </channel>
</rss>

