<?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 Reading Data into SAS - Missing Some Data and Separated with Commas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-Data-into-SAS-Missing-Some-Data-and-Separated-with/m-p/781795#M249168</link>
    <description>&lt;P&gt;I have a data set in a file that is separated with commas, missing data is simply left blank, and is made of characters and numbers. I need to read the data file into SAS and print the data set, but I believe the commas and missing data is not being read into SAS properly. I have attached a photo of the data set, the code I used, and the table SAS generated. How do I fix the code to read the data properly?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas.PNG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66023i49970698313EDACC/image-size/large?v=v2&amp;amp;px=999" role="button" title="sas.PNG" alt="sas.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;DATA BenAndJerrys;&lt;BR /&gt;INFILE 'C:\Users\165\Downloads\BenAndJerrys.dat';&lt;BR /&gt;INPUT FlavorName $ PortionSize Calories CaloriesFromFat Fat SaturatedFat TransFat Cholesterol Sodium TotalCarbohydrates DietaryFiber Sugars Proteins YearIntroduced YearRetired ContentDescription $ Notes $ ;&lt;BR /&gt;PROC PRINT;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas2.PNG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66024i906DDF6CE0137734/image-size/large?v=v2&amp;amp;px=999" role="button" title="sas2.PNG" alt="sas2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 22 Nov 2021 22:33:20 GMT</pubDate>
    <dc:creator>eslb2022</dc:creator>
    <dc:date>2021-11-22T22:33:20Z</dc:date>
    <item>
      <title>Reading Data into SAS - Missing Some Data and Separated with Commas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Data-into-SAS-Missing-Some-Data-and-Separated-with/m-p/781795#M249168</link>
      <description>&lt;P&gt;I have a data set in a file that is separated with commas, missing data is simply left blank, and is made of characters and numbers. I need to read the data file into SAS and print the data set, but I believe the commas and missing data is not being read into SAS properly. I have attached a photo of the data set, the code I used, and the table SAS generated. How do I fix the code to read the data properly?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas.PNG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66023i49970698313EDACC/image-size/large?v=v2&amp;amp;px=999" role="button" title="sas.PNG" alt="sas.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;DATA BenAndJerrys;&lt;BR /&gt;INFILE 'C:\Users\165\Downloads\BenAndJerrys.dat';&lt;BR /&gt;INPUT FlavorName $ PortionSize Calories CaloriesFromFat Fat SaturatedFat TransFat Cholesterol Sodium TotalCarbohydrates DietaryFiber Sugars Proteins YearIntroduced YearRetired ContentDescription $ Notes $ ;&lt;BR /&gt;PROC PRINT;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas2.PNG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66024i906DDF6CE0137734/image-size/large?v=v2&amp;amp;px=999" role="button" title="sas2.PNG" alt="sas2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 22:33:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Data-into-SAS-Missing-Some-Data-and-Separated-with/m-p/781795#M249168</guid>
      <dc:creator>eslb2022</dc:creator>
      <dc:date>2021-11-22T22:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Data into SAS - Missing Some Data and Separated with Commas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Data-into-SAS-Missing-Some-Data-and-Separated-with/m-p/781796#M249169</link>
      <description>&lt;P&gt;Where you have multiple commas in a row, and each marks a separate variable, you can tell SAS to expect that and accomodate it by adding dsd:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;INFILE 'C:\Users\lgb156\Downloads\BenAndJerrys.dat' dsd;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Nov 2021 21:45:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Data-into-SAS-Missing-Some-Data-and-Separated-with/m-p/781796#M249169</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-11-22T21:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Data into SAS - Missing Some Data and Separated with Commas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Data-into-SAS-Missing-Some-Data-and-Separated-with/m-p/781798#M249170</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you try to put the&amp;nbsp;&lt;SPAN style="font-family: inherit;"&gt;DSD option on the INFILE statement?&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV id="n0somgznlxvbj7n1mch6s2ngruz8" class="xisDoc-exampleBlock"&gt;
&lt;DIV class="xisDoc-example"&gt;
&lt;P class="xisDoc-paragraph"&gt;The DSD option sets the comma as the default delimiter and if there are two adjacent commas it means two delimiters (a missing value is supposed to be in-between the two commas).&lt;/P&gt;
&lt;P class="xisDoc-paragraph"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="xisDoc-paragraph"&gt;Koen&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 22 Nov 2021 21:47:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Data-into-SAS-Missing-Some-Data-and-Separated-with/m-p/781798#M249170</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-11-22T21:47:43Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Data into SAS - Missing Some Data and Separated with Commas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Data-into-SAS-Missing-Some-Data-and-Separated-with/m-p/781803#M249173</link>
      <description>&lt;P&gt;That worked, but&amp;nbsp;&lt;SPAN&gt;the flavor name and description columns will not fill with the entire context. The image shows that the Flavor Name for "Banana Split" only says "Banana: in the cell. How do I tell SAS to put the entire context in the cell?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 22:07:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Data-into-SAS-Missing-Some-Data-and-Separated-with/m-p/781803#M249173</guid>
      <dc:creator>eslb2022</dc:creator>
      <dc:date>2021-11-22T22:07:36Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Data into SAS - Missing Some Data and Separated with Commas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Data-into-SAS-Missing-Some-Data-and-Separated-with/m-p/781806#M249174</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The default delimiter is a blank, so that's why it outputs "Banana" to your first variable and not "Banana Split".&lt;/P&gt;
&lt;P&gt;With adding DSD option on the INFILE statement, you should also solve that, no??&lt;/P&gt;
&lt;P&gt;If not we can work with an informat.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 22:13:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Data-into-SAS-Missing-Some-Data-and-Separated-with/m-p/781806#M249174</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-11-22T22:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Data into SAS - Missing Some Data and Separated with Commas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Data-into-SAS-Missing-Some-Data-and-Separated-with/m-p/781807#M249175</link>
      <description>&lt;P&gt;You didn't define your variables before using them in the INPUT statement.&amp;nbsp; So SAS was forced the GUESS how to define them based on how you used them first.&amp;nbsp; Your input statement provides no other information it can use to guess other than the $ modifier so it will default all of the variables to use a length of 8. The ones with the $ after them it will default to character.&amp;nbsp; Any variable that did not have the $ modifier after it will default to numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add a LENGTH statement before the INPUT statement to set the length (and type) of the variables.&amp;nbsp; Once the type is known you don't need the $ modifiers in the INPUT statement anymore.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 22:29:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Data-into-SAS-Missing-Some-Data-and-Separated-with/m-p/781807#M249175</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-22T22:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Data into SAS - Missing Some Data and Separated with Commas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Data-into-SAS-Missing-Some-Data-and-Separated-with/m-p/781808#M249176</link>
      <description>&lt;P&gt;You could also add informats in the INPUT to give SAS some additional information to base its guess of how to define the variables.&amp;nbsp; But make sure to use the : modifier so that the input statement does not read past or stop short of the delimiters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA BenAndJerrys;
  INFILE 'C:\Users\lgb156\Downloads\BenAndJerrys.dat' dsd truncover;
  INPUT FlavorName :$30. PortionSize Calories CaloriesFromFat Fat SaturatedFat 
        TransFat Cholesterol Sodium TotalCarbohydrates DietaryFiber Sugars 
        Proteins YearIntroduced YearRetired 
        ContentDescription :$50. Notes :$200. 
   ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Nov 2021 22:32:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Data-into-SAS-Missing-Some-Data-and-Separated-with/m-p/781808#M249176</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-22T22:32:38Z</dc:date>
    </item>
  </channel>
</rss>

