<?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: Retain leading and trailing spaces  when import the csv files into SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Retain-leading-and-trailing-spaces-when-import-the-csv-files/m-p/531761#M145619</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/148952"&gt;@daisy6&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for the help. But for the trailing space, how to deal with that? like:&lt;/P&gt;
&lt;P&gt;"ItemKey","Response","Iscorret'&lt;BR /&gt;"4615313059","contribution","correct"&lt;/P&gt;
&lt;P&gt;"4615313067","contribution&amp;nbsp; ","not correct"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;because I keep these two different response&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If using dsd, the import dataset is the same as using proc import.&amp;nbsp; If not using dsd, the dataset will keep the quote symbol. Is any better way to deal with my case? Thanks a lot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since the code submitted with DSD was generated by Proc Import you should not be surprised that the sets are the same as proc import.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; mentioned, trailing blanks are a very problematic issue. If you do not want the quotes then before removing the quotes you would have to supply some character other than a blank and then for whatever purpose you consider a trailing blank significant that character would have to suffice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Personally I am having a very hard time coming up with a use case for a significant difference between a trailing blank and not.&lt;/P&gt;
&lt;P&gt;Leading blanks, possibly, though even then I would spend a certain amount of time in how one leading blank is actually significantly different than two or more leading blanks for most purposes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you provide an explicit example of your process that fails because the trailing blank is "not there"? Or is this hypothetical and no other processing code has been written yet?&lt;/P&gt;</description>
    <pubDate>Thu, 31 Jan 2019 19:02:36 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-01-31T19:02:36Z</dc:date>
    <item>
      <title>Retain leading and trailing spaces  when import the csv files into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-leading-and-trailing-spaces-when-import-the-csv-files/m-p/531712#M145584</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to keep the leading and trailing spaces when import the csv files into SAS. For example,&lt;/P&gt;&lt;P&gt;hoping SAS treat the below response as different.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"ItemKey","Response",&lt;BR /&gt;"4615313059","contribution&amp;nbsp; "&lt;BR /&gt;"4615313067","&amp;nbsp; &amp;nbsp;contribution"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;however, when I use:&lt;/P&gt;&lt;P&gt;filename xfile "datadir\test.csv" encoding="utf-8" lrecl=532767;&lt;BR /&gt;proc import datafile=xfile out=test1 dbms=csv replace;&lt;BR /&gt;getnames=yes;&lt;BR /&gt;datarow=2;&lt;BR /&gt;guessingrows=592767;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS treat them as the same. Can somebody help me out?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2019 16:58:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-leading-and-trailing-spaces-when-import-the-csv-files/m-p/531712#M145584</guid>
      <dc:creator>daisy6</dc:creator>
      <dc:date>2019-01-31T16:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: Retain leading and trailing spaces  when import the csv files into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-leading-and-trailing-spaces-when-import-the-csv-files/m-p/531715#M145586</link>
      <description>&lt;P&gt;PROC IMPORT will not do this, you'll have to write a custom data step to import the file and specify the information using CHAR to get the leading and trailing spaces.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Trailing spaces always exist in SAS, depending on the length of the variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/148952"&gt;@daisy6&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to keep the leading and trailing spaces when import the csv files into SAS. For example,&lt;/P&gt;
&lt;P&gt;hoping SAS treat the below response as different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"ItemKey","Response",&lt;BR /&gt;"4615313059","contribution&amp;nbsp; "&lt;BR /&gt;"4615313067","&amp;nbsp; &amp;nbsp;contribution"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;however, when I use:&lt;/P&gt;
&lt;P&gt;filename xfile "datadir\test.csv" encoding="utf-8" lrecl=532767;&lt;BR /&gt;proc import datafile=xfile out=test1 dbms=csv replace;&lt;BR /&gt;getnames=yes;&lt;BR /&gt;datarow=2;&lt;BR /&gt;guessingrows=592767;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS treat them as the same. Can somebody help me out?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2019 17:05:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-leading-and-trailing-spaces-when-import-the-csv-files/m-p/531715#M145586</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-31T17:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: Retain leading and trailing spaces  when import the csv files into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-leading-and-trailing-spaces-when-import-the-csv-files/m-p/531716#M145587</link>
      <description>&lt;P&gt;Proc import generates data step code. Copy that code to the editor and modify.&lt;/P&gt;
&lt;P&gt;If you remove the option DSD on the infile statement. That &lt;STRONG&gt;might &lt;/STRONG&gt;work for you need if your data does not contain any commas in the value of &lt;STRONG&gt;any&lt;/STRONG&gt; of your fields. You might have to strip out quote marks though. If your actual data does not have quotes then we will have to go back to the drawing board and require some parsing of your file differently.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Compare the results from these two data steps with and without DSD.&lt;/P&gt;
&lt;PRE&gt;data work.want;
   infile datalines dlm=',' ;
   informat itemkey $12. response $25.;
   input itemkey response;

datalines;
"4615313059","contribution  "
"4615313067","   contribution"
;
run;

data work.want2;
   infile datalines dlm=',' dsd;
   informat itemkey $12. response $25.;
   input itemkey response;

datalines;
"4615313059","contribution  "
"4615313067","   contribution"
;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Jan 2019 17:07:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-leading-and-trailing-spaces-when-import-the-csv-files/m-p/531716#M145587</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-01-31T17:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: Retain leading and trailing spaces  when import the csv files into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-leading-and-trailing-spaces-when-import-the-csv-files/m-p/531724#M145592</link>
      <description>&lt;P&gt;Thanks for the help. But for the trailing space, how to deal with that? like:&lt;/P&gt;&lt;P&gt;"ItemKey","Response","Iscorret'&lt;BR /&gt;"4615313059","contribution","correct"&lt;/P&gt;&lt;P&gt;"4615313067","contribution&amp;nbsp; ","not correct"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;because I keep these two different response&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If using dsd, the import dataset is the same as using proc import.&amp;nbsp; If not using dsd, the dataset will keep the quote symbol. Is any better way to deal with my case? Thanks a lot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2019 17:24:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-leading-and-trailing-spaces-when-import-the-csv-files/m-p/531724#M145592</guid>
      <dc:creator>daisy6</dc:creator>
      <dc:date>2019-01-31T17:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: Retain leading and trailing spaces  when import the csv files into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-leading-and-trailing-spaces-when-import-the-csv-files/m-p/531761#M145619</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/148952"&gt;@daisy6&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for the help. But for the trailing space, how to deal with that? like:&lt;/P&gt;
&lt;P&gt;"ItemKey","Response","Iscorret'&lt;BR /&gt;"4615313059","contribution","correct"&lt;/P&gt;
&lt;P&gt;"4615313067","contribution&amp;nbsp; ","not correct"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;because I keep these two different response&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If using dsd, the import dataset is the same as using proc import.&amp;nbsp; If not using dsd, the dataset will keep the quote symbol. Is any better way to deal with my case? Thanks a lot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since the code submitted with DSD was generated by Proc Import you should not be surprised that the sets are the same as proc import.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; mentioned, trailing blanks are a very problematic issue. If you do not want the quotes then before removing the quotes you would have to supply some character other than a blank and then for whatever purpose you consider a trailing blank significant that character would have to suffice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Personally I am having a very hard time coming up with a use case for a significant difference between a trailing blank and not.&lt;/P&gt;
&lt;P&gt;Leading blanks, possibly, though even then I would spend a certain amount of time in how one leading blank is actually significantly different than two or more leading blanks for most purposes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you provide an explicit example of your process that fails because the trailing blank is "not there"? Or is this hypothetical and no other processing code has been written yet?&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2019 19:02:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-leading-and-trailing-spaces-when-import-the-csv-files/m-p/531761#M145619</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-01-31T19:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: Retain leading and trailing spaces  when import the csv files into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-leading-and-trailing-spaces-when-import-the-csv-files/m-p/531785#M145631</link>
      <description>&lt;P&gt;I cann't provide you the exact data for private information. However, I believe that you already gave me a good idea to deal with the leading and trailing space problem. Thank you for the reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2019 20:01:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-leading-and-trailing-spaces-when-import-the-csv-files/m-p/531785#M145631</guid>
      <dc:creator>daisy6</dc:creator>
      <dc:date>2019-01-31T20:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: Retain leading and trailing spaces  when import the csv files into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-leading-and-trailing-spaces-when-import-the-csv-files/m-p/531815#M145644</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/148952"&gt;@daisy6&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I cann't provide you the exact data for private information. However, I believe that you already gave me a good idea to deal with the leading and trailing space problem. Thank you for the reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Just for the record, I was requesting anything related to sensitive data values, just an example of how processing could be affected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2019 21:08:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-leading-and-trailing-spaces-when-import-the-csv-files/m-p/531815#M145644</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-01-31T21:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: Retain leading and trailing spaces  when import the csv files into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-leading-and-trailing-spaces-when-import-the-csv-files/m-p/532009#M145732</link>
      <description>&lt;P&gt;I have to say, if there were two comma next to each other, Your code would generate the error result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data work.want2;
   infile datalines dsd;
   input (itemkey x response) (: ~ $40.);

datalines;
"4615313059",,"contribution  "
"4615313067",,"   contribution"
;
run;

proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Feb 2019 14:20:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-leading-and-trailing-spaces-when-import-the-csv-files/m-p/532009#M145732</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-02-01T14:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Retain leading and trailing spaces  when import the csv files into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-leading-and-trailing-spaces-when-import-the-csv-files/m-p/681178#M206015</link>
      <description>&lt;P&gt;Use ~ modifier along with informat $char25. Informat "Char" will preserve the leading spaces no matter if column is in quotes or not.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.want3;
   infile datalines dsd;
   input itemkey :$12. response ~ $char25.;
datalines;
"4615313059","contribution  "
"4615313067","   contribution"
"4615313067",   contribution
"4615313067",   contribution
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Sep 2020 23:14:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-leading-and-trailing-spaces-when-import-the-csv-files/m-p/681178#M206015</guid>
      <dc:creator>kulbshar</dc:creator>
      <dc:date>2020-09-02T23:14:22Z</dc:date>
    </item>
  </channel>
</rss>

