<?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: Leading Blanks in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Leading-Blanks/m-p/51214#M10727</link>
    <description>The leading blanks are preserved if you use $char informat. Here is an example run on my 9.2 (TS1M0), windows platform:&lt;BR /&gt;&lt;BR /&gt;
&lt;BR /&gt;&lt;BR /&gt;
&lt;B&gt;&lt;SPAN style="color:#000080;font-family:Courier New;font-size:10pt;"&gt;data&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;one;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;@&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="color:#008080;font-family:Courier New;font-size:10pt;"&gt;21&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;count&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#008080;font-family:Courier New;font-size:10pt;"&gt;$char8.&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;----+----1----+----2----+----3&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;SC010024201103241201&amp;nbsp;1468&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;B&gt;&lt;SPAN style="color:#000080;font-family:Courier New;font-size:10pt;"&gt;run&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;B&gt;&lt;SPAN style="color:#000080;font-family:Courier New;font-size:10pt;"&gt;proc&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="color:#000080;font-family:Courier New;font-size:10pt;"&gt;print&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;=one;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;B&gt;&lt;SPAN style="color:#000080;font-family:Courier New;font-size:10pt;"&gt;run&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;/*&amp;nbsp;on&amp;nbsp;lst&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;Obs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;count&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;----+---&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1468&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;*/&lt;/SPAN&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 15 Apr 2011 19:38:16 GMT</pubDate>
    <dc:creator>chang_y_chung_hotmail_com</dc:creator>
    <dc:date>2011-04-15T19:38:16Z</dc:date>
    <item>
      <title>Leading Blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Leading-Blanks/m-p/51210#M10723</link>
      <description>I am trying to import data from a text file, and I need to keep the leading blanks.  Here is what I am using:&lt;BR /&gt;
&lt;BR /&gt;
@0021    SubmissionRecordCount $CHAR8.&lt;BR /&gt;
&lt;BR /&gt;
Data is:&lt;BR /&gt;
&lt;BR /&gt;
SC010024201103241201    1468&lt;BR /&gt;
&lt;BR /&gt;
However, even with the CHAR informat, it still loses the blanks.  &lt;BR /&gt;
&lt;BR /&gt;
I would appreciate any help!&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Chris</description>
      <pubDate>Fri, 15 Apr 2011 16:05:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Leading-Blanks/m-p/51210#M10723</guid>
      <dc:creator>cjohnson</dc:creator>
      <dc:date>2011-04-15T16:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: Leading Blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Leading-Blanks/m-p/51211#M10724</link>
      <description>One way of looking at the problem is that you're not losing the blanks, you are just left aligning your character variable.  So right align it and add blanks.  The RIGHT function will right-align the variable when output.</description>
      <pubDate>Fri, 15 Apr 2011 18:05:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Leading-Blanks/m-p/51211#M10724</guid>
      <dc:creator>Benjy</dc:creator>
      <dc:date>2011-04-15T18:05:28Z</dc:date>
    </item>
    <item>
      <title>Re: Leading Blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Leading-Blanks/m-p/51212#M10725</link>
      <description>Your code is working exactly as expected.  You can use the justification format modifier to right justify the value in the field.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
80   data _null_;&lt;BR /&gt;
81      length SubmissionRecordCount $8;&lt;BR /&gt;
82      input @0021 SubmissionRecordCount $CHAR8.-R;&lt;BR /&gt;
83      put '12345678';&lt;BR /&gt;
84      put (S:) ($char20.);&lt;BR /&gt;
85      cards;&lt;BR /&gt;
&lt;BR /&gt;
12345678&lt;BR /&gt;
    1468&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
If you change the variable length the justifcation is unexpected. &lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data _null_;&lt;BR /&gt;
   length SubmissionRecordCount $20;&lt;BR /&gt;
   input @0021 SubmissionRecordCount $CHAR8.-R;&lt;BR /&gt;
   put '12345678901234567890';&lt;BR /&gt;
   put (S:) ($char20.);&lt;BR /&gt;
   cards;&lt;BR /&gt;
SC010024201103241201 1468&lt;BR /&gt;
;;;;&lt;BR /&gt;
   run;[/pre]&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
125  data _null_;&lt;BR /&gt;
126     length SubmissionRecordCount $20;&lt;BR /&gt;
127     input @0021 SubmissionRecordCount $CHAR8.-R;&lt;BR /&gt;
128     put '12345678901234567890';&lt;BR /&gt;
129     put (S:) ($char20.);&lt;BR /&gt;
130     cards;&lt;BR /&gt;
&lt;BR /&gt;
12345678901234567890&lt;BR /&gt;
                1468&lt;BR /&gt;
[/pre]</description>
      <pubDate>Fri, 15 Apr 2011 18:57:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Leading-Blanks/m-p/51212#M10725</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-04-15T18:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: Leading Blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Leading-Blanks/m-p/51213#M10726</link>
      <description>I took data_null_'s code and dropped the "-R" and got what I think that cjohnson is looking for.  (SAS 9.2 TS2M3).&lt;BR /&gt;
&lt;BR /&gt;
cjohnson, If you are still having problems, maybe you can explain more fully.  Another way to debug this is to print the data with the hex format so you can precisely tell what is in there.&lt;BR /&gt;
&lt;BR /&gt;
Doc Muhlbaier&lt;BR /&gt;
Duke&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
   length SubmissionRecordCount $20;&lt;BR /&gt;
   input @0021 SubmissionRecordCount $CHAR8.;&lt;BR /&gt;
   put '12345678901234567890';&lt;BR /&gt;
   put (S:) ($char20.);&lt;BR /&gt;
   cards;&lt;BR /&gt;
SC010024201103241201 1468&lt;BR /&gt;
;;;;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
10   data _null_;&lt;BR /&gt;
11      length SubmissionRecordCount $20;&lt;BR /&gt;
12      input @0021 SubmissionRecordCount $CHAR8.;&lt;BR /&gt;
13      put '12345678901234567890';&lt;BR /&gt;
14      put (S:) ($char20.);&lt;BR /&gt;
15      cards;&lt;BR /&gt;
&lt;BR /&gt;
12345678901234567890&lt;BR /&gt;
 1468</description>
      <pubDate>Fri, 15 Apr 2011 19:15:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Leading-Blanks/m-p/51213#M10726</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2011-04-15T19:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: Leading Blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Leading-Blanks/m-p/51214#M10727</link>
      <description>The leading blanks are preserved if you use $char informat. Here is an example run on my 9.2 (TS1M0), windows platform:&lt;BR /&gt;&lt;BR /&gt;
&lt;BR /&gt;&lt;BR /&gt;
&lt;B&gt;&lt;SPAN style="color:#000080;font-family:Courier New;font-size:10pt;"&gt;data&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;one;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;@&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="color:#008080;font-family:Courier New;font-size:10pt;"&gt;21&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;count&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#008080;font-family:Courier New;font-size:10pt;"&gt;$char8.&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;----+----1----+----2----+----3&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;SC010024201103241201&amp;nbsp;1468&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;B&gt;&lt;SPAN style="color:#000080;font-family:Courier New;font-size:10pt;"&gt;run&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;B&gt;&lt;SPAN style="color:#000080;font-family:Courier New;font-size:10pt;"&gt;proc&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="color:#000080;font-family:Courier New;font-size:10pt;"&gt;print&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;=one;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;B&gt;&lt;SPAN style="color:#000080;font-family:Courier New;font-size:10pt;"&gt;run&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;/*&amp;nbsp;on&amp;nbsp;lst&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;Obs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;count&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;----+---&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1468&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;*/&lt;/SPAN&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 15 Apr 2011 19:38:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Leading-Blanks/m-p/51214#M10727</guid>
      <dc:creator>chang_y_chung_hotmail_com</dc:creator>
      <dc:date>2011-04-15T19:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: Leading Blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Leading-Blanks/m-p/51215#M10728</link>
      <description>Ah...you are right.  The leading blanks were being preserved.  I couldn't see it in the table view, but when I also added the $char format to the export, it kept the blanks.  Thanks very much!</description>
      <pubDate>Mon, 18 Apr 2011 17:25:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Leading-Blanks/m-p/51215#M10728</guid>
      <dc:creator>cjohnson</dc:creator>
      <dc:date>2011-04-18T17:25:43Z</dc:date>
    </item>
  </channel>
</rss>

