<?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: &amp;quot;.&amp;quot; for missing character data will not code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/quot-quot-for-missing-character-data-will-not-code/m-p/884677#M349510</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if strip(trim(bene_death_dt)) = "." then died = 0;
else died = 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Try removing any extra spaces using TRIM/STRIP()?&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jul 2023 15:52:14 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2023-07-13T15:52:14Z</dc:date>
    <item>
      <title>"." for missing character data will not code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-quot-for-missing-character-data-will-not-code/m-p/884675#M349509</link>
      <description>&lt;P&gt;I have received a data set with a date (bene_death_dt) coded as an 8 digit character string (according to proc contents).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I check values of the variable with proc freq, it show that missing data is noted with a period.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No matter how I write my code, I cannot reference those values of "." and do anything with them.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, I want to code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if bene_death_dt = "." then died = 0;&lt;/P&gt;
&lt;P&gt;else died = 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The result is that all values of bene_death_dt are assigned to died=1, including those that are "."&lt;/P&gt;
&lt;P&gt;I get no errors in my log.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm stumped and would appreciate any pointers on where to check for issues.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2023 15:49:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-quot-for-missing-character-data-will-not-code/m-p/884675#M349509</guid>
      <dc:creator>greesamu</dc:creator>
      <dc:date>2023-07-13T15:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: "." for missing character data will not code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-quot-for-missing-character-data-will-not-code/m-p/884677#M349510</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if strip(trim(bene_death_dt)) = "." then died = 0;
else died = 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Try removing any extra spaces using TRIM/STRIP()?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2023 15:52:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-quot-for-missing-character-data-will-not-code/m-p/884677#M349510</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-07-13T15:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: "." for missing character data will not code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-quot-for-missing-character-data-will-not-code/m-p/884678#M349511</link>
      <description>Huzzah, thank you so much!</description>
      <pubDate>Thu, 13 Jul 2023 15:55:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-quot-for-missing-character-data-will-not-code/m-p/884678#M349511</guid>
      <dc:creator>greesamu</dc:creator>
      <dc:date>2023-07-13T15:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: "." for missing character data will not code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-quot-for-missing-character-data-will-not-code/m-p/884681#M349513</link>
      <description>&lt;P&gt;First I would double-check that PROC CONTENTS shows you that this variable is defined as CHARACTER, rather than NUMERIC.&amp;nbsp; Sometimes people do stored dates in a CHARACTER variable, but it's not a good idea.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it really is character, then I would think you may have a problem with leading blanks in your data.&amp;nbsp; So you could try something simple like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if left(bene_death_dt) = "." then died = 0;
else died = 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If that doesn't work then you might have other unprintable characters (e.g. tabs) in your character value you could try:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if compress(bene_death_dt,,'C') = "." then died = 0;
else died = 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If either of those work, you would want to go back an clean the data in bene_death_dt.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2023 16:06:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-quot-for-missing-character-data-will-not-code/m-p/884681#M349513</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-07-13T16:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: "." for missing character data will not code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-quot-for-missing-character-data-will-not-code/m-p/884685#M349516</link>
      <description>&lt;P&gt;Including TRIM() is not adding anything.&lt;/P&gt;
&lt;P&gt;TRIM() removes trailing spaces (which SAS ignores anyway).&lt;/P&gt;
&lt;P&gt;STRIP() remove leading and trailing spaces.&lt;/P&gt;
&lt;P&gt;LEFT() removes leading spaces, which all you really need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One way to create a character variable with a period and leading spaces is to use the PUT() function with a missing value.&amp;nbsp; In that case the period will put in the character position of the WIDTH of the format used.&amp;nbsp; So code like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;string=put(date,date9.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Will generate a string with 8 spaces followed by a period.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note such leading spaces are made even harder to see if you display your data use ODS output (which is now the default) since ODS "eats" the leading spaces for some unknown reason.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also avoid generating the period at all by changing the character used in the MISSING option to a space instead of the default period before running the step that used the PUT() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2023 16:31:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-quot-for-missing-character-data-will-not-code/m-p/884685#M349516</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-13T16:31:50Z</dc:date>
    </item>
  </channel>
</rss>

