<?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: Determining a space value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Determining-a-space-value/m-p/80788#M288401</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the SAS world a blank is treated as NULL. There is no specific NULL value and a character variable has also always a length of at least '1'.&lt;/P&gt;&lt;P&gt;For your requirement to work you would have to replace these "blanks" with 'N' before you map a SAS variable against it - or if you read the data from an external file you could determine the blanks by checking how much the pointer has moved for reading the next value as done in sample code below. &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;filename source temp;&lt;BR /&gt;data _null_;&lt;BR /&gt;&amp;nbsp; file source;&lt;BR /&gt;&amp;nbsp; put "Blank, ,it is";&lt;BR /&gt;&amp;nbsp; put "NULL,,it is";&lt;BR /&gt;&amp;nbsp; put "it is,blank, ";&lt;BR /&gt;&amp;nbsp; put "it is,NULL,";&lt;BR /&gt;&amp;nbsp; put;&lt;BR /&gt;&amp;nbsp; put " ";&lt;BR /&gt;&amp;nbsp; put ", ";&lt;BR /&gt;&amp;nbsp; put "&amp;nbsp;&amp;nbsp; ,";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test(drop=_:);&lt;BR /&gt;&amp;nbsp; infile source dsd truncover col=CurCol dlm=',';&lt;/P&gt;&lt;P&gt;&amp;nbsp; _PrevCol=1;&lt;BR /&gt;&amp;nbsp; input a:$10. @;&lt;BR /&gt;&amp;nbsp; if _PrevCol+1&amp;gt;=CurCol then a='N';&lt;/P&gt;&lt;P&gt;&amp;nbsp; _PrevCol=CurCol;&lt;BR /&gt;&amp;nbsp; input b:$10. @;&lt;BR /&gt;&amp;nbsp; if _PrevCol+1&amp;gt;=CurCol then b='N';&lt;/P&gt;&lt;P&gt;&amp;nbsp; _PrevCol=CurCol;&lt;BR /&gt;&amp;nbsp; input c:$10. ;&lt;BR /&gt;&amp;nbsp; if _PrevCol+1&amp;gt;=CurCol then c='N';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 05 Aug 2012 10:12:48 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2012-08-05T10:12:48Z</dc:date>
    <item>
      <title>Determining a space value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Determining-a-space-value/m-p/80785#M288398</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm doing data cleansing on source data. The rule is if attribute (text) = space, attribute = 'N'.&amp;nbsp;&amp;nbsp; How do I code SAS so it doesn't intrepret ' ' as null?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Aug 2012 02:48:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Determining-a-space-value/m-p/80785#M288398</guid>
      <dc:creator>Mike7085</dc:creator>
      <dc:date>2012-08-01T02:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: Determining a space value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Determining-a-space-value/m-p/80786#M288399</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mike,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You probably will have to provide an example.&amp;nbsp; As you can see, with the following, you can always identify characters according to their actual byte value.&amp;nbsp; A space would be a 32, while a null would be a zero.&amp;nbsp; e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; file "c:\art\fortest.txt";&lt;/P&gt;&lt;P&gt;&amp;nbsp; put "Now is the time";&lt;/P&gt;&lt;P&gt;&amp;nbsp; put "The time was then";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile "c:\art\fortest.txt";&lt;/P&gt;&lt;P&gt;&amp;nbsp; input;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=1 to length(_infile_);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x=substr(_infile_,i,1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; y=rank(x);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; put y;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Aug 2012 03:12:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Determining-a-space-value/m-p/80786#M288399</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-08-01T03:12:16Z</dc:date>
    </item>
    <item>
      <title>Re: Determining a space value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Determining-a-space-value/m-p/80787#M288400</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;if I enter the following code, :&lt;/P&gt;&lt;P&gt;IF FLDA = ' ' THEN FLDA = 'N' ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAS interprets this as ==&amp;gt;&amp;nbsp; if flda is null then flda = 'N'&amp;nbsp; what I want to do is put in a command so SAS interprets it as&lt;/P&gt;&lt;P&gt;if flda = space then flda = 'N'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Aug 2012 05:32:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Determining-a-space-value/m-p/80787#M288400</guid>
      <dc:creator>Mike7085</dc:creator>
      <dc:date>2012-08-01T05:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: Determining a space value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Determining-a-space-value/m-p/80788#M288401</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the SAS world a blank is treated as NULL. There is no specific NULL value and a character variable has also always a length of at least '1'.&lt;/P&gt;&lt;P&gt;For your requirement to work you would have to replace these "blanks" with 'N' before you map a SAS variable against it - or if you read the data from an external file you could determine the blanks by checking how much the pointer has moved for reading the next value as done in sample code below. &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;filename source temp;&lt;BR /&gt;data _null_;&lt;BR /&gt;&amp;nbsp; file source;&lt;BR /&gt;&amp;nbsp; put "Blank, ,it is";&lt;BR /&gt;&amp;nbsp; put "NULL,,it is";&lt;BR /&gt;&amp;nbsp; put "it is,blank, ";&lt;BR /&gt;&amp;nbsp; put "it is,NULL,";&lt;BR /&gt;&amp;nbsp; put;&lt;BR /&gt;&amp;nbsp; put " ";&lt;BR /&gt;&amp;nbsp; put ", ";&lt;BR /&gt;&amp;nbsp; put "&amp;nbsp;&amp;nbsp; ,";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test(drop=_:);&lt;BR /&gt;&amp;nbsp; infile source dsd truncover col=CurCol dlm=',';&lt;/P&gt;&lt;P&gt;&amp;nbsp; _PrevCol=1;&lt;BR /&gt;&amp;nbsp; input a:$10. @;&lt;BR /&gt;&amp;nbsp; if _PrevCol+1&amp;gt;=CurCol then a='N';&lt;/P&gt;&lt;P&gt;&amp;nbsp; _PrevCol=CurCol;&lt;BR /&gt;&amp;nbsp; input b:$10. @;&lt;BR /&gt;&amp;nbsp; if _PrevCol+1&amp;gt;=CurCol then b='N';&lt;/P&gt;&lt;P&gt;&amp;nbsp; _PrevCol=CurCol;&lt;BR /&gt;&amp;nbsp; input c:$10. ;&lt;BR /&gt;&amp;nbsp; if _PrevCol+1&amp;gt;=CurCol then c='N';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 05 Aug 2012 10:12:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Determining-a-space-value/m-p/80788#M288401</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-08-05T10:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: Determining a space value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Determining-a-space-value/m-p/80789#M288402</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SAS character variables are fixed length and padded on the right with spaces. So there is no concept of a NULL character variable. &lt;/P&gt;&lt;P&gt;If you are talking about testing input from a text file or a macro variable then you might be able to distinguish between a field with nothing in it versus a field with a space in it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 05 Aug 2012 14:20:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Determining-a-space-value/m-p/80789#M288402</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-08-05T14:20:22Z</dc:date>
    </item>
  </channel>
</rss>

