<?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: [University Edition] Beginner: Using input to create multiple character columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/University-Edition-Beginner-Using-input-to-create-multiple/m-p/404106#M98233</link>
    <description>&lt;P&gt;Oh wait, it just needs to be&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input Student $ (Q1-Q150) ($) ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you Reeza!&lt;/P&gt;</description>
    <pubDate>Fri, 13 Oct 2017 20:01:47 GMT</pubDate>
    <dc:creator>thorifyer</dc:creator>
    <dc:date>2017-10-13T20:01:47Z</dc:date>
    <item>
      <title>[University Edition] Beginner: Using input to create multiple character columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/University-Edition-Beginner-Using-input-to-create-multiple/m-p/404085#M98229</link>
      <description>&lt;P&gt;I'm trying to read in a 51 row by 151 column .csv file&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The first column is&amp;nbsp;Student ID #&lt;/LI&gt;&lt;LI&gt;The remaining columns are the questions of an exam&lt;/LI&gt;&lt;LI&gt;The first row is the key to the exam&lt;/LI&gt;&lt;LI&gt;The remaining rows are the answers submitted by the student&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Here is the the first portion of the data in Excel.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="image.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15881iE30E30974231A8C2/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;Is there a&amp;nbsp;way to importing the data with the columns being character vectors without needing to state each individual column as a character?&lt;/P&gt;&lt;P&gt;When I try to read in the date with the code below, only Student and Q150 are character vectors. The cells of Q1 through Q149 are blank (to be more accurate, they're periods). [Edit: They are blank because they are still numeric]&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Exam_Results;
	infile "filepath.csv" dlm="," dsd;
	input Student $ Q1-Q150 $;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I'm trying to avoid is something obnoxious like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Exam_Results;
	infile "filepath.csv" dlm="," dsd;
	input Student $ Q1 $ Q2 $ Q3 $ Q4 $ Q5 $ Q6 $ Q7 $ Q8 $ Q9 $ Q0 $ Q10 $ ... Q149 $ Q150 $;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there some easier, more concise to get all of the columns imported as characters?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advanced everyone.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 19:36:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/University-Edition-Beginner-Using-input-to-create-multiple/m-p/404085#M98229</guid>
      <dc:creator>thorifyer</dc:creator>
      <dc:date>2017-10-13T19:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: [University Edition] Beginner: Using input to create multiple character columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/University-Edition-Beginner-Using-input-to-create-multiple/m-p/404095#M98230</link>
      <description>&lt;P&gt;Lazy import method.&lt;/P&gt;
&lt;P&gt;1. Use PROC IMPORT, set GUESSINGROWS to MAX.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Copy code from log, removing line numbers and modify that code as required.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to manually specify a bunch of columns you can do so with the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input Student $ (Q1-Q150) $ ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I would possibly consider doing two reads personally, the first one would be just the first row with the key and a second with the answers from students. You can use the FIRSTOBS option along with the OBS option to limit what you read.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 19:44:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/University-Edition-Beginner-Using-input-to-create-multiple/m-p/404095#M98230</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-13T19:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: [University Edition] Beginner: Using input to create multiple character columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/University-Edition-Beginner-Using-input-to-create-multiple/m-p/404105#M98232</link>
      <description>&lt;P&gt;When I run&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Exam_Results;
	infile "/folders/myfolders/124/Final Project/FormA.csv" dlm=",";
	input Student_ID $ (Q1-Q150) $ ;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I get this error in my log.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 61         
 62         data Exam_Results;
 63         infile "/folders/myfolders/124/Final Project/FormA.csv" dlm=",";
 64         input Student_ID $ (Q1-Q150) $ ;
                                          _
                                          79
                                          76
 ERROR 79-322: Expecting a (.
 
 ERROR 76-322: Syntax error, statement will be ignored.
 
 65         run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Am I just missing something here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 19:56:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/University-Edition-Beginner-Using-input-to-create-multiple/m-p/404105#M98232</guid>
      <dc:creator>thorifyer</dc:creator>
      <dc:date>2017-10-13T19:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: [University Edition] Beginner: Using input to create multiple character columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/University-Edition-Beginner-Using-input-to-create-multiple/m-p/404106#M98233</link>
      <description>&lt;P&gt;Oh wait, it just needs to be&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input Student $ (Q1-Q150) ($) ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you Reeza!&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 20:01:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/University-Edition-Beginner-Using-input-to-create-multiple/m-p/404106#M98233</guid>
      <dc:creator>thorifyer</dc:creator>
      <dc:date>2017-10-13T20:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: [University Edition] Beginner: Using input to create multiple character columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/University-Edition-Beginner-Using-input-to-create-multiple/m-p/404119#M98236</link>
      <description>&lt;P&gt;Just define your variables before trying to use them in the INPUT statement.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Exam_Results;
  length Student $20 Q1-Q150 $1 ;
  infile "filepath.csv" dsd truncover;
  input Student Q1-Q150 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In most cases it is better to define your variables instead of forcing SAS to guess at what you wanted them to be based on how you first reference the variable in some other statement whether it is INPUT, FORMAT, INFORMAT or an assignment statement.&amp;nbsp; Plus once the variables are defined your INPUT statement is much easier to write.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 20:24:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/University-Edition-Beginner-Using-input-to-create-multiple/m-p/404119#M98236</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-13T20:24:53Z</dc:date>
    </item>
  </channel>
</rss>

