<?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: How to include space in sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-include-space-in-sas/m-p/308288#M66136</link>
    <description>&lt;P&gt;SAS will not track that information for you.&amp;nbsp; If you look at only SAS and ignore the DBMS side of the equation, consider these statements:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;if sex='F' then gender='Female';&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;else gender='Male';&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the SAS data set, GENDER has a fixed length of 6.&amp;nbsp; When GENDER is "Male", SAS actually stores 4 nonblanks plus two blanks.&amp;nbsp; Any of these later statements would find the same sets of matches:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;if gender='Male' then do;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;if gender='Male ' then do;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;if gender='Male&amp;nbsp; ' then do;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When SAS detects that GENDER contains 6 characters, it automatically pads the string on the right with blanks to reach a length of 6 and then checks for equality.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS never tracks how many blanks were there in the original DBMS value.&amp;nbsp; It can retrieve the number of nonblanks:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;L = lengthn(fieldname);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are certain that L+1 is the original number of characters from the DBMS, you can program upon that assumption.&amp;nbsp; But the values stored within a SAS character field routinely pad with blanks to reach a fixed length for each field.&lt;/P&gt;</description>
    <pubDate>Mon, 31 Oct 2016 14:46:17 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-10-31T14:46:17Z</dc:date>
    <item>
      <title>How to include space in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-include-space-in-sas/m-p/308273#M66125</link>
      <description>&lt;P&gt;Hi Everyone!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to import data fro emp table from IBM schema into SAS. Data in one of the column (i.e. Empname) in Oracle contain extra space at the end of text. I need to capture those spaces after importing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem is that those spaces at the end are automatically ignored by the SAS. Is there any way to change the below code to capture exact data that are present in Oracle table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt; connect to oracle (user=abc orapw=bcd path=efg);&lt;BR /&gt; create table work.emp as&lt;BR /&gt; Select * from connection to&amp;nbsp;oracle&lt;BR /&gt;(SELECT * FROM IBM.Employee &lt;BR /&gt;);&lt;/P&gt;
&lt;P&gt;disconnect from oracle;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 14:03:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-include-space-in-sas/m-p/308273#M66125</guid>
      <dc:creator>Abraham</dc:creator>
      <dc:date>2016-10-31T14:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to include space in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-include-space-in-sas/m-p/308275#M66127</link>
      <description>&lt;P&gt;Do you mean that columns in SAS have been defined shorter than they were in the DBMS?&lt;/P&gt;
&lt;P&gt;If they have the same length, they are always padded with blanks.&lt;/P&gt;
&lt;P&gt;What gives you the impression that blanks have been omitted?&lt;/P&gt;
&lt;P&gt;If you have doubt, display your names with a HEXw. format, w being double the defined length of the column.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 14:08:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-include-space-in-sas/m-p/308275#M66127</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-10-31T14:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to include space in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-include-space-in-sas/m-p/308277#M66129</link>
      <description>&lt;P&gt;yes,&amp;nbsp;&lt;SPAN&gt;column in SAS have been defined same length as&amp;nbsp;oracle column.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Column after importing contain same length as in DBMS.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;E.g suppose the variable in empname contain value as 'Apple &amp;nbsp;' &amp;nbsp; (two space at the end).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;After importing, SAS capture the same text without any space i.e. 'Apple'&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 14:17:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-include-space-in-sas/m-p/308277#M66129</guid>
      <dc:creator>Abraham</dc:creator>
      <dc:date>2016-10-31T14:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to include space in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-include-space-in-sas/m-p/308279#M66130</link>
      <description>&lt;P&gt;Yes, this is the&amp;nbsp;default behaviour in SAS, right or wrong.&lt;/P&gt;
&lt;P&gt;This is probably due to the fact that SAS handles a single space as MISSING&amp;nbsp;(similar to NULL in RDBMS).&lt;/P&gt;
&lt;P&gt;But does your trailing spaces has business meaning? How&amp;nbsp;do you &amp;nbsp;intend to use this information?&lt;/P&gt;
&lt;P&gt;In most scenarios they arn't being used, hence the SAS default behaviour.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 14:21:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-include-space-in-sas/m-p/308279#M66130</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-10-31T14:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to include space in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-include-space-in-sas/m-p/308280#M66131</link>
      <description>&lt;P&gt;Yes, I need to capture those record for data cleaning. Is there any possibility to capture those record&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 14:27:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-include-space-in-sas/m-p/308280#M66131</guid>
      <dc:creator>Abraham</dc:creator>
      <dc:date>2016-10-31T14:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to include space in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-include-space-in-sas/m-p/308284#M66133</link>
      <description>&lt;P&gt;Sorry, but I can't follow you. SAS character variables are always padded with blanks, from the last character to the defined length.&lt;/P&gt;
&lt;P&gt;See this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
length name $10;
name = 'Apple';
testname = put(name,$hex20.);
run;

proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Obs    name           testname

 1     Apple    4170706C652020202020
&lt;/PRE&gt;
&lt;P&gt;If you feel that there is something other in your variables but blanks, use the $HEX format to display it.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 14:33:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-include-space-in-sas/m-p/308284#M66133</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-10-31T14:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to include space in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-include-space-in-sas/m-p/308288#M66136</link>
      <description>&lt;P&gt;SAS will not track that information for you.&amp;nbsp; If you look at only SAS and ignore the DBMS side of the equation, consider these statements:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;if sex='F' then gender='Female';&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;else gender='Male';&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the SAS data set, GENDER has a fixed length of 6.&amp;nbsp; When GENDER is "Male", SAS actually stores 4 nonblanks plus two blanks.&amp;nbsp; Any of these later statements would find the same sets of matches:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;if gender='Male' then do;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;if gender='Male ' then do;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;if gender='Male&amp;nbsp; ' then do;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When SAS detects that GENDER contains 6 characters, it automatically pads the string on the right with blanks to reach a length of 6 and then checks for equality.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS never tracks how many blanks were there in the original DBMS value.&amp;nbsp; It can retrieve the number of nonblanks:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;L = lengthn(fieldname);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are certain that L+1 is the original number of characters from the DBMS, you can program upon that assumption.&amp;nbsp; But the values stored within a SAS character field routinely pad with blanks to reach a fixed length for each field.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 14:46:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-include-space-in-sas/m-p/308288#M66136</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-31T14:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to include space in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-include-space-in-sas/m-p/308310#M66146</link>
      <description>Record?&lt;BR /&gt;The record will not be filtered, it's the column value that will benable trimmed. &lt;BR /&gt;What type of cleansing operations will you perform?</description>
      <pubDate>Mon, 31 Oct 2016 16:33:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-include-space-in-sas/m-p/308310#M66146</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-10-31T16:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to include space in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-include-space-in-sas/m-p/308428#M66186</link>
      <description>&lt;PRE&gt;
Maybe you can use the Oracle function like sas's  lengthm() to get that character variable length.


proc sql;
connect to oracle (user=abc orapw=bcd path=efg);
create table work.emp as
Select * from connection to oracle
(SELECT * ,  lengthm(char_var)  as len  FROM IBM.Employee 
);
disconnect from oracle;
quit;

&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Nov 2016 04:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-include-space-in-sas/m-p/308428#M66186</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-11-01T04:36:09Z</dc:date>
    </item>
  </channel>
</rss>

