<?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 read a data with delimiter semicolon? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283130#M57658</link>
    <description>Got it . Thank you !!</description>
    <pubDate>Sat, 09 Jul 2016 08:45:21 GMT</pubDate>
    <dc:creator>RavenWu</dc:creator>
    <dc:date>2016-07-09T08:45:21Z</dc:date>
    <item>
      <title>How to read a data with delimiter semicolon?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283028#M57608</link>
      <description>&lt;P&gt;The result&amp;nbsp;required is:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/3975iE77CC3CDF64A7466/image-size/large?v=v2&amp;amp;px=-1" border="0" alt="result.png" title="result.png" /&gt;&lt;/P&gt;&lt;P&gt;the dataset is in attachment, and my codes are&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA Names;&lt;/P&gt;&lt;PRE&gt; DATA Names;
 INFILE  'D:\names.txt' dlm=';';
 
 IF gender= "M" THEN gender_dummy= 1;
 eLSE IF gender= "F" THEN gender_dummy= 0;

 
 IF inservice &amp;lt; 2013 THEN bestpos=q1;
 ELSE bestpos=1;
 worstpos=q3;
 
 RUN;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my result is&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/3976i162AEFD39ABEC3F6/image-size/large?v=v2&amp;amp;px=-1" border="0" alt="my result.png" title="my result.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I think,&amp;nbsp;the first 6 variables are original variables and we could just read them in and tell the SAS to seperate them by delimeter &lt;STRONG&gt;";"&lt;/STRONG&gt;, and&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;the last 4 variables are newly created variables. Except for the variable "serviceyrs", I can't&amp;nbsp;deduce how it come from, so we can just ignore this column. It is weird that the orignal variables can't be correctly&amp;nbsp;read in, and the final result is totally incorrect. Could anyone know what's the problem with my codes?&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2016 19:17:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283028#M57608</guid>
      <dc:creator>RavenWu</dc:creator>
      <dc:date>2016-07-08T19:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a data with delimiter semicolon?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283029#M57609</link>
      <description>&lt;P&gt;I can't see the INPUT statement. Did you forget something important? &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;regards Jan.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2016 19:23:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283029#M57609</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2016-07-08T19:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a data with delimiter semicolon?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283037#M57614</link>
      <description>&lt;P&gt;I would look to use the import wizard or task for a text file. Tell the wizard the delimiter is ;. Should take care of reading.&lt;/P&gt;
&lt;P&gt;If you want to add additional variables at the same time you should be able to find the datastep generated by the wizard in the log. You could copy and paste that into the editor/code node or which ever and add the lines you have for the additional variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2016 19:38:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283037#M57614</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-07-08T19:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a data with delimiter semicolon?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283040#M57617</link>
      <description>Since the names of the first 6 variables are aready given in the head line of the data set, I assume we don't need an input statement to specify the variable anymore.</description>
      <pubDate>Fri, 08 Jul 2016 19:48:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283040#M57617</guid>
      <dc:creator>RavenWu</dc:creator>
      <dc:date>2016-07-08T19:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a data with delimiter semicolon?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283043#M57620</link>
      <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;, but the codes generated by import wizard have too many lines. I think there is just some small problems with my codes, and we can actually use the simple SAS codes to read the data correctly. I just don't know how to do yet.</description>
      <pubDate>Fri, 08 Jul 2016 20:01:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283043#M57620</guid>
      <dc:creator>RavenWu</dc:creator>
      <dc:date>2016-07-08T20:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a data with delimiter semicolon?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283044#M57621</link>
      <description>&lt;P&gt;The problem with your code is obvious. You need an INPUT statement. Your assumption about thsi being automatic due to that first line in your code is wrong. It is PROC IMPORT that can do that; not the datasytep.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Remember to skip that first line. Use INFILE ... FIRSTOBS=2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards, Jan.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2016 20:04:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283044#M57621</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2016-07-08T20:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a data with delimiter semicolon?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283046#M57623</link>
      <description>&lt;P&gt;Your code would be (not tested):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA Names;
    length name $100 gender $1 inservice q1 q2 q3 8;
    INFILE  'D:\names.txt' dlm=';' fitrsobs=2;
    input name $ gender $ inservice q1 q2 q3;

...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;- Jan.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2016 20:10:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283046#M57623</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2016-07-08T20:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a data with delimiter semicolon?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283057#M57627</link>
      <description>&lt;P&gt;If you are worried about multiple INFORMAT and FORMAT statements that is NOT too many lines. You only would have a dozen or so of those and one input statement spanning 8 or nine lines. A 40 or 50 line program to read data when YOU don't have to type all of it is minor.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I routinely deal with this for up to 200 variables. I end up with over 800 lines for some of these things. Adding Labels so the variables have some meaning, diagnostic code, cleaning values and&amp;nbsp;adding additional analysis or reporting variables adds more. That is all routine and tedious but the programs are not "too big".&lt;/P&gt;
&lt;P&gt;The idea is that you can reduce them in the editor, many of the formats especially for character variables for instance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But once you have the program when you need to read a similar file later you just point to the new data source and give the data set a new name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2016 20:40:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283057#M57627</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-07-08T20:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a data with delimiter semicolon?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283058#M57628</link>
      <description>You are right. Thank you so much !!</description>
      <pubDate>Fri, 08 Jul 2016 20:40:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283058#M57628</guid>
      <dc:creator>RavenWu</dc:creator>
      <dc:date>2016-07-08T20:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a data with delimiter semicolon?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283063#M57631</link>
      <description>If this works for you, please mark this resolved.&lt;BR /&gt;&lt;BR /&gt;- Jan</description>
      <pubDate>Fri, 08 Jul 2016 20:51:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283063#M57631</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2016-07-08T20:51:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a data with delimiter semicolon?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283129#M57657</link>
      <description>Ok. I am a new user and I will always do that in the future</description>
      <pubDate>Sat, 09 Jul 2016 08:41:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283129#M57657</guid>
      <dc:creator>RavenWu</dc:creator>
      <dc:date>2016-07-09T08:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a data with delimiter semicolon?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283130#M57658</link>
      <description>Got it . Thank you !!</description>
      <pubDate>Sat, 09 Jul 2016 08:45:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-data-with-delimiter-semicolon/m-p/283130#M57658</guid>
      <dc:creator>RavenWu</dc:creator>
      <dc:date>2016-07-09T08:45:21Z</dc:date>
    </item>
  </channel>
</rss>

