<?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: Dealing with Logical Skip Values in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/Dealing-with-Logical-Skip-Values/m-p/948989#M10953</link>
    <description>&lt;P&gt;First you may want to share what you think you want to do with the&amp;nbsp; "skip" variable.&lt;/P&gt;
&lt;P&gt;I'm not seeing anything obvious for a variable named Employment what that would contribute to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, do you see an L in the data set for either of those variables? If the variable is numeric and you see L then that means the variable has been assigned a special missing, which is a dot plus a letter or the underscore character. In which case you can test for the special value by using .L&lt;/P&gt;
&lt;P&gt;These special missing values will appear in table views or printed output as upper case letters even when assigned with lower case.&lt;/P&gt;
&lt;P&gt;How to use:&lt;/P&gt;
&lt;PRE&gt;If variable = .L then do &amp;lt;whatever you were going to do&amp;gt;.&lt;/PRE&gt;
&lt;P&gt;An example creating a special missing and printing:&lt;/P&gt;
&lt;PRE&gt;data junk;
   x=.a;
run;

proc print data=junk;
run;&lt;/PRE&gt;
&lt;P&gt;One reason for special missing values is that you can test for the condition(s) and use differently than a basic missing. Or create a custom format to display different text such as "Skipped" or "Not Answered" or "Refused" so you have more information about why at least some of the values are missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If a variable essentially has two values it is often quite advantageous to code the values as 1/ 0 where the 1 goes to the level most often of interest.&lt;/P&gt;
&lt;P&gt;Reason is many tasks become much simpler. If the values were 1/0 with 1=Employed and 0=unemployed then&lt;/P&gt;
&lt;PRE&gt;employment= sum(Parent1, Parent2);&lt;/PRE&gt;
&lt;P&gt;would mean: employment=2 both employed, 1= only one employed, 0=no adult employed. You would get a missing value only if both of the variables were missing. Reason to use sum function is Parent1+Partent2 would return a missing value if either of the variables were missing.&lt;/P&gt;</description>
    <pubDate>Thu, 24 Oct 2024 22:37:13 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-10-24T22:37:13Z</dc:date>
    <item>
      <title>Dealing with Logical Skip Values</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Dealing-with-Logical-Skip-Values/m-p/948985#M10951</link>
      <description>I have two variables for employment status: one for parent 1 and another for parent 2. There are 3 values for both of them.&lt;BR /&gt;1-employed&lt;BR /&gt;2-unemployed&lt;BR /&gt;and L-logical skip if parent is not alive.&lt;BR /&gt;&lt;BR /&gt;I would like to create a new variable out of both variables using the logical step value.&lt;BR /&gt;&lt;BR /&gt;This is my code:&lt;BR /&gt;data version2017;&lt;BR /&gt;set version2017;&lt;BR /&gt;if Parent1=1 AND parent2=1 then employment=1; *Both parents employed;&lt;BR /&gt;else if (parent1=1 AND parent2 IN (2,.)) OR (parent1 IN (2, .) AND parent2=1) then employment=2; *at least one parent employed;&lt;BR /&gt;else if parent1=2 AND parent2=2 then employment=3; *no adult employed;&lt;BR /&gt;else employment =.;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;Unfortunately, my code doesn’t work. I am unable to treat L as a character because my variable is numeric. How can I factor L into my code?</description>
      <pubDate>Thu, 24 Oct 2024 22:17:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Dealing-with-Logical-Skip-Values/m-p/948985#M10951</guid>
      <dc:creator>darkrainbow</dc:creator>
      <dc:date>2024-10-24T22:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: Dealing with Logical Skip Values</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Dealing-with-Logical-Skip-Values/m-p/948987#M10952</link>
      <description>&lt;P&gt;If your variable Parent1 is numeric (run PROC CONTENTS to check the type) and you see values that display as "L" in PROC PRINT or PROC FREQ, then the value is a numeric SPECIAL MISSING VALUE.&amp;nbsp; &amp;nbsp; See e.g.:&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/lrcon/9.4/p1xr9fm7y8kek5n1hpj008tnu1a1.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/lrcon/9.4/p1xr9fm7y8kek5n1hpj008tnu1a1.htm&lt;/A&gt;&amp;nbsp;or the first SAS paper I wrote, 23 years ago:&amp;nbsp;&lt;A href="https://www.lexjansen.com/nesug/nesug01/ps/ps8009.pdf" target="_blank"&gt;https://www.lexjansen.com/nesug/nesug01/ps/ps8009.pdf&lt;/A&gt;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can refer to the value in code like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if Parent1=.L AND parent2=.L then employment=.L; *neither parent is alive;&lt;/CODE&gt;&lt;/PRE&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, 24 Oct 2024 22:27:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Dealing-with-Logical-Skip-Values/m-p/948987#M10952</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-10-24T22:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: Dealing with Logical Skip Values</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Dealing-with-Logical-Skip-Values/m-p/948989#M10953</link>
      <description>&lt;P&gt;First you may want to share what you think you want to do with the&amp;nbsp; "skip" variable.&lt;/P&gt;
&lt;P&gt;I'm not seeing anything obvious for a variable named Employment what that would contribute to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, do you see an L in the data set for either of those variables? If the variable is numeric and you see L then that means the variable has been assigned a special missing, which is a dot plus a letter or the underscore character. In which case you can test for the special value by using .L&lt;/P&gt;
&lt;P&gt;These special missing values will appear in table views or printed output as upper case letters even when assigned with lower case.&lt;/P&gt;
&lt;P&gt;How to use:&lt;/P&gt;
&lt;PRE&gt;If variable = .L then do &amp;lt;whatever you were going to do&amp;gt;.&lt;/PRE&gt;
&lt;P&gt;An example creating a special missing and printing:&lt;/P&gt;
&lt;PRE&gt;data junk;
   x=.a;
run;

proc print data=junk;
run;&lt;/PRE&gt;
&lt;P&gt;One reason for special missing values is that you can test for the condition(s) and use differently than a basic missing. Or create a custom format to display different text such as "Skipped" or "Not Answered" or "Refused" so you have more information about why at least some of the values are missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If a variable essentially has two values it is often quite advantageous to code the values as 1/ 0 where the 1 goes to the level most often of interest.&lt;/P&gt;
&lt;P&gt;Reason is many tasks become much simpler. If the values were 1/0 with 1=Employed and 0=unemployed then&lt;/P&gt;
&lt;PRE&gt;employment= sum(Parent1, Parent2);&lt;/PRE&gt;
&lt;P&gt;would mean: employment=2 both employed, 1= only one employed, 0=no adult employed. You would get a missing value only if both of the variables were missing. Reason to use sum function is Parent1+Partent2 would return a missing value if either of the variables were missing.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2024 22:37:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Dealing-with-Logical-Skip-Values/m-p/948989#M10953</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-10-24T22:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: Dealing with Logical Skip Values</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Dealing-with-Logical-Skip-Values/m-p/948996#M10954</link>
      <description>&lt;P&gt;Unless you have some user defined format attached to the variable then numbers that PRINT as the single letter uppercase L contain the special missing value of .L .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you can test if the value is .L exactly using one of these ways:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;parent1 = .L
parent1 = .l
parent1 in (.L)
parent1 in (.l)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you can test if it has any of the 28 different missing values that SAS supports by using the MISSING function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;missing(parent1)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Oct 2024 02:42:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Dealing-with-Logical-Skip-Values/m-p/948996#M10954</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-10-25T02:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: Dealing with Logical Skip Values</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Dealing-with-Logical-Skip-Values/m-p/949283#M10955</link>
      <description>&lt;P&gt;This worked. Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2024 17:41:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Dealing-with-Logical-Skip-Values/m-p/949283#M10955</guid>
      <dc:creator>darkrainbow</dc:creator>
      <dc:date>2024-10-28T17:41:44Z</dc:date>
    </item>
  </channel>
</rss>

