<?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: Move an observation to the next variable column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Move-an-observation-to-the-next-variable-column/m-p/479282#M286494</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm actually not sure how to fix that in the import process. Do you have any steps available?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Jul 2018 21:19:52 GMT</pubDate>
    <dc:creator>Ramsha</dc:creator>
    <dc:date>2018-07-18T21:19:52Z</dc:date>
    <item>
      <title>Move an observation to the next variable column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Move-an-observation-to-the-next-variable-column/m-p/479274#M286492</link>
      <description>&lt;P&gt;Suppose I have set variable names: City, State, Zip from a csv import! Not datalines.&amp;nbsp;&lt;/P&gt;&lt;P&gt;New York&amp;nbsp; NY 11001&lt;/P&gt;&lt;P&gt;Baltimore&amp;nbsp; MD 12231&lt;/P&gt;&lt;P&gt;Raleigh&amp;nbsp; &amp;nbsp; &amp;nbsp;NC 32435&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In observation 3, the NC was incorrectly formatted to the City variable which thus moved the Zip into the State variable. How do you fix or format an imported csv/excel?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 20:59:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Move-an-observation-to-the-next-variable-column/m-p/479274#M286492</guid>
      <dc:creator>Ramsha</dc:creator>
      <dc:date>2018-07-18T20:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: Move an observation to the next variable column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Move-an-observation-to-the-next-variable-column/m-p/479281#M286493</link>
      <description>&lt;P&gt;Ideally you fix this in the import process. Is that possible here?&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/181583"&gt;@Ramsha&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Suppose I have set variable names: City, State, Zip from a csv import! Not datalines.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;New York&amp;nbsp; NY 11001&lt;/P&gt;
&lt;P&gt;Baltimore&amp;nbsp; MD 12231&lt;/P&gt;
&lt;P&gt;Raleigh&amp;nbsp; &amp;nbsp; &amp;nbsp;NC 32435&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In observation 3, the NC was incorrectly formatted to the City variable which thus moved the Zip into the State variable. How do you fix or format an imported csv/excel?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 21:17:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Move-an-observation-to-the-next-variable-column/m-p/479281#M286493</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-18T21:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: Move an observation to the next variable column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Move-an-observation-to-the-next-variable-column/m-p/479282#M286494</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm actually not sure how to fix that in the import process. Do you have any steps available?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 21:19:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Move-an-observation-to-the-next-variable-column/m-p/479282#M286494</guid>
      <dc:creator>Ramsha</dc:creator>
      <dc:date>2018-07-18T21:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: Move an observation to the next variable column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Move-an-observation-to-the-next-variable-column/m-p/479283#M286495</link>
      <description>&lt;P&gt;How did you import the data? Did you write a PROC IMPORT or a DATA STEP or use the point and click commands?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you know where the error originates? Is it in the raw data or is it being read incorrectly?&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/181583"&gt;@Ramsha&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm actually not sure how to fix that in the import process. Do you have any steps available?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 21:25:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Move-an-observation-to-the-next-variable-column/m-p/479283#M286495</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-18T21:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: Move an observation to the next variable column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Move-an-observation-to-the-next-variable-column/m-p/479286#M286496</link>
      <description>I suspect you need the DSD option in the data step, but not sure if that can be added via PROC IMPORT.</description>
      <pubDate>Wed, 18 Jul 2018 21:28:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Move-an-observation-to-the-next-variable-column/m-p/479286#M286496</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-18T21:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Move an observation to the next variable column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Move-an-observation-to-the-next-variable-column/m-p/479288#M286497</link>
      <description>&lt;P&gt;I did a simple proc import.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC IMPORT DATAFILE=CSV&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OUT=Places&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DBMS=CSV&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; REPLACE;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand the issue with the Proc Import but unfortunately I can only use proc import in my situation. Is there any other way to manipulate the data?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 21:31:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Move-an-observation-to-the-next-variable-column/m-p/479288#M286497</guid>
      <dc:creator>Ramsha</dc:creator>
      <dc:date>2018-07-18T21:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: Move an observation to the next variable column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Move-an-observation-to-the-next-variable-column/m-p/479289#M286498</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/181583"&gt;@Ramsha&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Suppose I have set variable names: City, State, Zip from a csv import! Not datalines.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;New York&amp;nbsp; NY 11001&lt;/P&gt;
&lt;P&gt;Baltimore&amp;nbsp; MD 12231&lt;/P&gt;
&lt;P&gt;Raleigh&amp;nbsp; &amp;nbsp; &amp;nbsp;NC 32435&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In observation 3, the NC was incorrectly formatted to the City variable which thus moved the Zip into the State variable. How do you fix or format an imported csv/excel?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;With lots of routine and tedious code to fix stupid data entry errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there are only 3 variables involved and the data were only US and protectorates I would be tempted to settle for finding the zip code and then using the ZIP related functions SAS has to get the city and state:&lt;/P&gt;
&lt;P&gt;Zip = scan(catx(' ',city,state,zip),-1);&lt;/P&gt;
&lt;P&gt;city = scan(zipcity(zip),1,',');&lt;/P&gt;
&lt;P&gt;state = zipstate(zip);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This assumes that your ZIP as recorded is accurate and that your sashelp.zipcode data is reasonably current.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise lots of string checking and validating as you pull pieces from here and there with functions such as Scan after identifying likely type of error: Zip in state field, city and state in City;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Zip and State in State field,&lt;/P&gt;
&lt;P&gt;Don't forget someone may have gotten real creative and managed to either duplicate or place part of City name in the State field, or recorded a City with a comma as part of the original City such a New, Town (which would mean zip value&amp;nbsp;is field AFTER the expected ZIP)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 21:32:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Move-an-observation-to-the-next-variable-column/m-p/479289#M286498</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-18T21:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: Move an observation to the next variable column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Move-an-observation-to-the-next-variable-column/m-p/479290#M286499</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I understand the issue with the Proc Import but unfortunately I can only use proc import in my situation. Is there any other way to manipulate the data?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Not easily. PROC IMPORT&amp;nbsp;assumes types, so in this case if you have&amp;nbsp;the same type you can correct it manually but that means checking each record systematically and knowing ahead of time all the possible/impossible values for the State/ZIP and doesn't preclude other issues.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The optimal solution is to use the data step code with the DSD&amp;nbsp;option.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;An alternative is use a data step to read it in but read each line as a&amp;nbsp;single character and manually process it. Again, this would not use PROC IMPORT. &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you can attach a&amp;nbsp;sample of your file it would help but if you're stuck using PROC IMPORT for whatever reason, you're stuck fixing each record manually AFAIK.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 21:36:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Move-an-observation-to-the-next-variable-column/m-p/479290#M286499</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-18T21:36:13Z</dc:date>
    </item>
  </channel>
</rss>

