<?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: Data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-step/m-p/253040#M48110</link>
    <description>&lt;P&gt;Look carefully at your INPUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" size="4"&gt;&lt;SPAN&gt;input AJCC $13;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Since there is no period after the 13 it is taken to mean a column number instead of an informat. So it means to read the 13th character. &amp;nbsp;That is why you do not see any of the values.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Also why did you set the delimiter to a comma on the INFILE statement? &amp;nbsp;If the file really is a CSV file with more than one column then you should use the DSD option to make sure missing values are properly handled. &amp;nbsp;If you just have a single column of values then it easiest to just read the value and not worry about delimiters. But you might want to add a TRUNCOVER option so that it properly handles lines with less than 13 characters.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;&lt;SPAN&gt;data cancer;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;&lt;SPAN&gt;&amp;nbsp; infile "C:\sas\bcancer.csv" firstobs=2 truncover;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;&lt;SPAN&gt;&amp;nbsp; input AJCC $13.;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 28 Feb 2016 16:07:45 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2016-02-28T16:07:45Z</dc:date>
    <item>
      <title>Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step/m-p/253024#M48106</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data contains variable called AJCC with the sub-variables: stage I, Stage II, Stage III, Stage IV, and Unknown Stage. But I keep getting missing output "Stage III". see the attached document for detail. Thank you for any help related to the problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;abuanuazu&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Feb 2016 13:42:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step/m-p/253024#M48106</guid>
      <dc:creator>abuanuazu</dc:creator>
      <dc:date>2016-02-28T13:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step/m-p/253026#M48107</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/48582"&gt;@abuanuazu﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First of all, something must be missing in your code, probably a SET statement reading another dataset. Otherwise, where should variable AJCC come from?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The reason why SAS seems to omit "Stage III" is most likely that you did not specify a sufficient length for character variable AJCC in the other dataset. There should be a statement like the following in the data step creating the dataset which contains AJCC:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length AJCC $9;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If there was no LENGTH statement for AJCC, this variable would be assigned the default length for character variabes, which is 8, or the length of the first value assigned to it. But the string "Stage III" has length 9. The last roman digit "I" would be truncated if AJCC had length 8. Hence, all values which should read "Stage III" would get the value "Stage II". Not surprisingly, "Stage 2" has a particularly large percentage in your output (because most probably it is in fact the union of Stage II and Stage III).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The same goes for variabe MYSTAGE. The value "Unknown Stage" is truncated to "Unknown" due to the missing length specification.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Feb 2016 14:26:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step/m-p/253026#M48107</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-28T14:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step/m-p/253035#M48108</link>
      <description>Thank you for your prompt response.&lt;BR /&gt;&lt;BR /&gt;This is the actual code:&lt;BR /&gt;Data cancer;&lt;BR /&gt;  Infile "C:\sas\bcancer.csv" dlm="," firstobs=2;&lt;BR /&gt;  Input AJCC $13;&lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;Data status;&lt;BR /&gt;   Set cancer;&lt;BR /&gt;    if AJCC="Stage I" then mystage="Stage 1";&lt;BR /&gt;    else if AJCC="Stage II" then mystage="Stage 2";&lt;BR /&gt;    else if AJCC="Stage III" then mystage="Stage 3";&lt;BR /&gt;    else if AJCC="Stage IV" then mystage="Stage 4";&lt;BR /&gt;    else&lt;BR /&gt;      mystage="Unknown Stage";&lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;proc freq data=status;&lt;BR /&gt;table mystage/chisq;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;initially to test the data i didn't assign length. After your response, I add length to AJCC $13 and execute the code. The output produce all the data to "unknown" 100% data.&lt;BR /&gt;&lt;BR /&gt;Any suggestion?</description>
      <pubDate>Sun, 28 Feb 2016 15:23:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step/m-p/253035#M48108</guid>
      <dc:creator>abuanuazu</dc:creator>
      <dc:date>2016-02-28T15:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step/m-p/253039#M48109</link>
      <description>&lt;P&gt;Your INPUT statement is invalid. [Edit: No, as pointed out by Tom, it's actually valid syntactically, although in&lt;EM&gt;correct&lt;/EM&gt;, in that it requests &lt;EM&gt;column&lt;/EM&gt; input (for column 13) both senselessly and in a misleading way.] &amp;nbsp;Either correct it to read&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input AJCC :$13.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or insert a LENGTH&amp;nbsp;statement before the INPUT statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length AJCC $13;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you can omit the informat specification completely and just write&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input AJCC;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The LENGTH&amp;nbsp;statement for MYSTAGE is still missing in the second data step.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Feb 2016 20:34:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step/m-p/253039#M48109</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-28T20:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step/m-p/253040#M48110</link>
      <description>&lt;P&gt;Look carefully at your INPUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" size="4"&gt;&lt;SPAN&gt;input AJCC $13;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Since there is no period after the 13 it is taken to mean a column number instead of an informat. So it means to read the 13th character. &amp;nbsp;That is why you do not see any of the values.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Also why did you set the delimiter to a comma on the INFILE statement? &amp;nbsp;If the file really is a CSV file with more than one column then you should use the DSD option to make sure missing values are properly handled. &amp;nbsp;If you just have a single column of values then it easiest to just read the value and not worry about delimiters. But you might want to add a TRUNCOVER option so that it properly handles lines with less than 13 characters.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;&lt;SPAN&gt;data cancer;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;&lt;SPAN&gt;&amp;nbsp; infile "C:\sas\bcancer.csv" firstobs=2 truncover;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;&lt;SPAN&gt;&amp;nbsp; input AJCC $13.;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Feb 2016 16:07:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step/m-p/253040#M48110</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-02-28T16:07:45Z</dc:date>
    </item>
    <item>
      <title>Re: Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step/m-p/254751#M48615</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for all help on Data Step question. I made a mistake in formating the real data from .xlsx to csv that cause all the problem.&lt;/P&gt;
&lt;P&gt;I used the orginal data import to SAS and works fine. Thank you all again. please see the attached&amp;nbsp; result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Abuanuazu&lt;/P&gt;</description>
      <pubDate>Sat, 05 Mar 2016 17:46:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step/m-p/254751#M48615</guid>
      <dc:creator>abuanuazu</dc:creator>
      <dc:date>2016-03-05T17:46:21Z</dc:date>
    </item>
  </channel>
</rss>

