<?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 Getting the Correct Character Length using the List Method in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Getting-the-Correct-Character-Length-using-the-List-Method/m-p/446314#M111956</link>
    <description>&lt;P&gt;Ok, I know this is pretty basic. But I need to get this right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I already have a set, and I know the variable names, I can use the scan function. However, when doing original data list,&lt;/P&gt;&lt;P&gt;my problem here is that the Location, such as New Jersey, has a space, so I am using the &amp;amp;, but there are cases where a $15. informat, for shorter location names, included data in the name field. I could just manually place spaces after the name to make sure that there are no numbers in the name, but there must be a better way to do this? Any thoughts would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Libname SasData '/folders/myfolders/SASData' ;&lt;BR /&gt;Data HIV_Surveillance ;&lt;BR /&gt;Input Residence_Location &amp;amp; $15.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Reported_Cases&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 8.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; All_Cases&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 8. ;&lt;BR /&gt;Datalines ;&lt;BR /&gt;Atlanta&amp;nbsp; 6355 14776&lt;BR /&gt;Baltimore 3490 10176&lt;BR /&gt;Boston 2769 9334&lt;/P&gt;&lt;P&gt;New Jersey 4893 9457&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Above, 6355 ends up with the name Atlanta. I could just increase the spaces after atlanta to make up the 15 characters, but is there a better way to do this? Thanks!&lt;/P&gt;</description>
    <pubDate>Fri, 16 Mar 2018 19:28:07 GMT</pubDate>
    <dc:creator>ManitobaMoose</dc:creator>
    <dc:date>2018-03-16T19:28:07Z</dc:date>
    <item>
      <title>Getting the Correct Character Length using the List Method</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-the-Correct-Character-Length-using-the-List-Method/m-p/446314#M111956</link>
      <description>&lt;P&gt;Ok, I know this is pretty basic. But I need to get this right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I already have a set, and I know the variable names, I can use the scan function. However, when doing original data list,&lt;/P&gt;&lt;P&gt;my problem here is that the Location, such as New Jersey, has a space, so I am using the &amp;amp;, but there are cases where a $15. informat, for shorter location names, included data in the name field. I could just manually place spaces after the name to make sure that there are no numbers in the name, but there must be a better way to do this? Any thoughts would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Libname SasData '/folders/myfolders/SASData' ;&lt;BR /&gt;Data HIV_Surveillance ;&lt;BR /&gt;Input Residence_Location &amp;amp; $15.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Reported_Cases&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 8.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; All_Cases&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 8. ;&lt;BR /&gt;Datalines ;&lt;BR /&gt;Atlanta&amp;nbsp; 6355 14776&lt;BR /&gt;Baltimore 3490 10176&lt;BR /&gt;Boston 2769 9334&lt;/P&gt;&lt;P&gt;New Jersey 4893 9457&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Above, 6355 ends up with the name Atlanta. I could just increase the spaces after atlanta to make up the 15 characters, but is there a better way to do this? Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 19:28:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-the-Correct-Character-Length-using-the-List-Method/m-p/446314#M111956</guid>
      <dc:creator>ManitobaMoose</dc:creator>
      <dc:date>2018-03-16T19:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the Correct Character Length using the List Method</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-the-Correct-Character-Length-using-the-List-Method/m-p/446327#M111961</link>
      <description>&lt;P&gt;Here are two different ways one requires the dsd option and quoting the values with a space in the middle. Second has TWO, no need to pad to 15)&amp;nbsp;spaces after the first variable for all records&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Data HIV_Surveillance ;
infile datalines dsd dlm=' ';
informat Residence_Location  $15.
      Reported_Cases      8.
      All_Cases           8. ;
Input Residence_Location 
      Reported_Cases     
      All_Cases          ;
Datalines ;
Atlanta 6355 14776
Baltimore 3490 10176
Boston 2769 9334
"New Jersey" 4893 9457
;

Data HIV_Surveillance ;
input Residence_Location &amp;amp; :$15.
      Reported_Cases      :8.
      All_Cases           :8. ;
Datalines ;
Atlanta  6355 14776
Baltimore  3490 10176
Boston  2769 9334
New Jersey  4893 9457
;
run;
&lt;/PRE&gt;
&lt;P&gt;Better might be to use another delimeter such as , or ; instead of default space&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 20:05:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-the-Correct-Character-Length-using-the-List-Method/m-p/446327#M111961</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-16T20:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the Correct Character Length using the List Method</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-the-Correct-Character-Length-using-the-List-Method/m-p/446444#M112007</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data HIV_Surveillance ;
input;
p=anydigit(_infile_);
Residence_Location=substr(_infile_,1,p-1);
      Reported_Cases=scan(substr(_infile_,p),1);
      All_Cases=scan(substr(_infile_,p),2);
      drop p;
Datalines ;
Atlanta  6355 14776
Baltimore 3490 10176
Boston 2769 9334
New Jersey 4893 9457
;


proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 17 Mar 2018 13:57:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-the-Correct-Character-Length-using-the-List-Method/m-p/446444#M112007</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-03-17T13:57:33Z</dc:date>
    </item>
  </channel>
</rss>

