<?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 How to contrast values of two variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-contrast-values-of-two-variables/m-p/112740#M31190</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The data look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data temp;&lt;/P&gt;&lt;P&gt;input Var1 Var2;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;5 .&lt;/P&gt;&lt;P&gt;7 .&lt;/P&gt;&lt;P&gt;8 .&lt;/P&gt;&lt;P&gt;2 1&lt;/P&gt;&lt;P&gt;3 1&lt;/P&gt;&lt;P&gt;1 2&lt;/P&gt;&lt;P&gt;1 4&lt;/P&gt;&lt;P&gt;4 5&lt;/P&gt;&lt;P&gt;6 5&lt;/P&gt;&lt;P&gt;6 7&lt;/P&gt;&lt;P&gt;6 8&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The idea is: there are cases where values of Var1 are equal to values of Var2 elsewhere while the corresponding values of Var2 are missing (values 5, 7, 8). The other specifications are not important I think.&lt;/P&gt;&lt;P&gt;How can I select values of Var2 as specified above (5, 7, &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; and turn them into missing (or whatever value)? That way it looks like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5 .&lt;/P&gt;&lt;P&gt;7 .&lt;/P&gt;&lt;P&gt;8 .&lt;/P&gt;&lt;P&gt;2 1&lt;/P&gt;&lt;P&gt;3 1&lt;/P&gt;&lt;P&gt;1 2&lt;/P&gt;&lt;P&gt;1 4&lt;/P&gt;&lt;P&gt;4 .&lt;/P&gt;&lt;P&gt;6 .&lt;/P&gt;&lt;P&gt;6 .&lt;/P&gt;&lt;P&gt;6 .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 15 Oct 2013 01:08:07 GMT</pubDate>
    <dc:creator>NonSleeper</dc:creator>
    <dc:date>2013-10-15T01:08:07Z</dc:date>
    <item>
      <title>How to contrast values of two variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-contrast-values-of-two-variables/m-p/112740#M31190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The data look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data temp;&lt;/P&gt;&lt;P&gt;input Var1 Var2;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;5 .&lt;/P&gt;&lt;P&gt;7 .&lt;/P&gt;&lt;P&gt;8 .&lt;/P&gt;&lt;P&gt;2 1&lt;/P&gt;&lt;P&gt;3 1&lt;/P&gt;&lt;P&gt;1 2&lt;/P&gt;&lt;P&gt;1 4&lt;/P&gt;&lt;P&gt;4 5&lt;/P&gt;&lt;P&gt;6 5&lt;/P&gt;&lt;P&gt;6 7&lt;/P&gt;&lt;P&gt;6 8&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The idea is: there are cases where values of Var1 are equal to values of Var2 elsewhere while the corresponding values of Var2 are missing (values 5, 7, 8). The other specifications are not important I think.&lt;/P&gt;&lt;P&gt;How can I select values of Var2 as specified above (5, 7, &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; and turn them into missing (or whatever value)? That way it looks like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5 .&lt;/P&gt;&lt;P&gt;7 .&lt;/P&gt;&lt;P&gt;8 .&lt;/P&gt;&lt;P&gt;2 1&lt;/P&gt;&lt;P&gt;3 1&lt;/P&gt;&lt;P&gt;1 2&lt;/P&gt;&lt;P&gt;1 4&lt;/P&gt;&lt;P&gt;4 .&lt;/P&gt;&lt;P&gt;6 .&lt;/P&gt;&lt;P&gt;6 .&lt;/P&gt;&lt;P&gt;6 .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Oct 2013 01:08:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-contrast-values-of-two-variables/m-p/112740#M31190</guid>
      <dc:creator>NonSleeper</dc:creator>
      <dc:date>2013-10-15T01:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to contrast values of two variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-contrast-values-of-two-variables/m-p/112741#M31191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table want as&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a.var1,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when missing(b.var1) then a.var2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;STRONG&gt;else b.var2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end as var2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; temp as a left join&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; temp as b on a.var2=b.var1;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit;&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>Tue, 15 Oct 2013 01:25:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-contrast-values-of-two-variables/m-p/112741#M31191</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-10-15T01:25:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to contrast values of two variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-contrast-values-of-two-variables/m-p/112742#M31192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Something like this.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt; select distinct var2 into :var2values separated by ' '&lt;BR /&gt; from temp&lt;BR /&gt; where var2 ne .&lt;BR /&gt; ;&lt;/P&gt;&lt;P&gt; select var1 into :missvar separated by ' '&lt;BR /&gt; from temp&lt;BR /&gt; where var2 eq . and var1 in (&amp;amp;var2values)&lt;BR /&gt; ;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;data out;&lt;BR /&gt; set temp;&lt;BR /&gt; if var2 in (&amp;amp;missvar) then var2 = .;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//Fredrik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Oct 2013 07:07:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-contrast-values-of-two-variables/m-p/112742#M31192</guid>
      <dc:creator>FredrikE</dc:creator>
      <dc:date>2013-10-15T07:07:27Z</dc:date>
    </item>
  </channel>
</rss>

