<?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 SODA importing CSV with titles not working - need help with input statement in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/SODA-importing-CSV-with-titles-not-working-need-help-with-input/m-p/838857#M36273</link>
    <description>&lt;P&gt;I'm either getting titles but no data or data but no titles. The rest of the code is written with these titles already!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using SODA and the file in question is a CSV that is already saved to my library (LIB). I'm just trying to read and work with it now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Help me out please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Correct data with wrong titles:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;libname ssd '/home/u59281773/sasuser.v94/LIB';
data redcap;
set '/home/u59281773/sasuser.v94/LIB/GC.sas7bdat';
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-10-16 at 11.39.10 AM.png" style="width: 544px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76236i89E7D564A986893B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2022-10-16 at 11.39.10 AM.png" alt="Screen Shot 2022-10-16 at 11.39.10 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Nonsense data with right titles:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;libname ssd '/home/u59281773/sasuser.v94/LIB';
data redcap;
INFILE '/home/u59281773/sasuser.v94/LIB/GC.csv';
input
    record_id $
    redcap_survey_identifier $
    gender_diversity_and_v_0 $
    consent
    help
    eligibilitygender
    eligibilitysick
/*about 200 more variable names*/
;
if _ERROR_ then call symput('_EFIERR_',"1");
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-10-16 at 11.37.14 AM.png" style="width: 956px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76235i9CDBEC8C422210BC/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2022-10-16 at 11.37.14 AM.png" alt="Screen Shot 2022-10-16 at 11.37.14 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Error messages:&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;NOTE: The infile '/home/u59281773/sasuser.v94/LIB/GC.csv' is:
Filename=/home/u59281773/sasuser.v94/LIB/GC.csv,
Owner Name=u59281773,Group Name=oda,
Access Permission=-rw-r--r--,
Last Modified=13Oct2022:20:50:57,
File Size (bytes)=47291

NOTE: Invalid data for consent in line 1 398-401.
NOTE: Invalid data for help in line 1 403-407.&amp;nbsp;&lt;/PRE&gt;For all 200 variables.&lt;/DIV&gt;</description>
    <pubDate>Sun, 16 Oct 2022 08:44:51 GMT</pubDate>
    <dc:creator>akimme</dc:creator>
    <dc:date>2022-10-16T08:44:51Z</dc:date>
    <item>
      <title>SODA importing CSV with titles not working - need help with input statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SODA-importing-CSV-with-titles-not-working-need-help-with-input/m-p/838857#M36273</link>
      <description>&lt;P&gt;I'm either getting titles but no data or data but no titles. The rest of the code is written with these titles already!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using SODA and the file in question is a CSV that is already saved to my library (LIB). I'm just trying to read and work with it now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Help me out please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Correct data with wrong titles:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;libname ssd '/home/u59281773/sasuser.v94/LIB';
data redcap;
set '/home/u59281773/sasuser.v94/LIB/GC.sas7bdat';
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-10-16 at 11.39.10 AM.png" style="width: 544px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76236i89E7D564A986893B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2022-10-16 at 11.39.10 AM.png" alt="Screen Shot 2022-10-16 at 11.39.10 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Nonsense data with right titles:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;libname ssd '/home/u59281773/sasuser.v94/LIB';
data redcap;
INFILE '/home/u59281773/sasuser.v94/LIB/GC.csv';
input
    record_id $
    redcap_survey_identifier $
    gender_diversity_and_v_0 $
    consent
    help
    eligibilitygender
    eligibilitysick
/*about 200 more variable names*/
;
if _ERROR_ then call symput('_EFIERR_',"1");
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-10-16 at 11.37.14 AM.png" style="width: 956px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76235i9CDBEC8C422210BC/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2022-10-16 at 11.37.14 AM.png" alt="Screen Shot 2022-10-16 at 11.37.14 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Error messages:&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;NOTE: The infile '/home/u59281773/sasuser.v94/LIB/GC.csv' is:
Filename=/home/u59281773/sasuser.v94/LIB/GC.csv,
Owner Name=u59281773,Group Name=oda,
Access Permission=-rw-r--r--,
Last Modified=13Oct2022:20:50:57,
File Size (bytes)=47291

NOTE: Invalid data for consent in line 1 398-401.
NOTE: Invalid data for help in line 1 403-407.&amp;nbsp;&lt;/PRE&gt;For all 200 variables.&lt;/DIV&gt;</description>
      <pubDate>Sun, 16 Oct 2022 08:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SODA-importing-CSV-with-titles-not-working-need-help-with-input/m-p/838857#M36273</guid>
      <dc:creator>akimme</dc:creator>
      <dc:date>2022-10-16T08:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: SODA importing CSV with titles not working - need help with input statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SODA-importing-CSV-with-titles-not-working-need-help-with-input/m-p/838859#M36275</link>
      <description>&lt;P&gt;Your infile statement needs some options added for SAS to "know" that this is a text file in a csv "layout". Also the input statement looks like it needs a bit of a workover in regards of informats.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May-be easiest for you is to use Proc Import and if you're not 100% happy with the result use the generated SAS datastep code as your starting point.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n02nz0e7cykqhun14hcppfmd0558.htm" target="_self"&gt;Example 4: Importing a Comma-Delimited File with a CSV Extension&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Oct 2022 09:10:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SODA-importing-CSV-with-titles-not-working-need-help-with-input/m-p/838859#M36275</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-10-16T09:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: SODA importing CSV with titles not working - need help with input statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SODA-importing-CSV-with-titles-not-working-need-help-with-input/m-p/838894#M36282</link>
      <description>&lt;P&gt;Do you have a SAS dataset?&amp;nbsp; That is a physical file with a .sas7bdat extension.&lt;/P&gt;
&lt;P&gt;That is what your first data step is reading.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or do you have a TEXT file?&amp;nbsp; That is what a CSV file is.&amp;nbsp; A file that consists of a series of lines.&amp;nbsp; Each line can have multiple fields that are separated by commas.&amp;nbsp; Although some people will use a different character is the delimiter between the fields and still use the .csv extension when naming the text file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I assume by "title" you mean the header text that is usually included in the first line of a CSV file?&amp;nbsp; Those are usually used to generate variable names.&amp;nbsp; But sometimes they are long strings that would work better as variable LABELS instead of NAMES.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How did create that second program?&amp;nbsp; Did you write it yourself?&amp;nbsp; Did someone give it to you?&amp;nbsp; Did SAS generate it?&amp;nbsp; The inclusion of that last statement&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if _ERROR_ then call symput('_EFIERR_',"1");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;makes it looks like something generated by PROC IMPORT or some IMPORT "task" or IMPORT "wizard".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The most likely reason the second data step did not work is you told SAS to read the file as if it was using space as the dlimiter instead of comma.&lt;/P&gt;
&lt;P&gt;Try fixing the INFILE statement and see if the second data step works better.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;INFILE '/home/u59281773/sasuser.v94/LIB/GC.csv' dsd truncover firstobs=2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;DSD says to treat adjacent delimiters as indicating an empty field. It also allows fields to be quoted so they could include the delimiter character.&amp;nbsp; It will also set the delimiter to a comma.&amp;nbsp; (You can change that by also including the DLM= option to specify a different delimiter character).&amp;nbsp; The TRUNCOVER option prevents it from trying to use more than one line for the same observation.&amp;nbsp; The FIRSTOBS=2 will tell it to skip the header line instead of trying to read that line as data also.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 03:56:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SODA-importing-CSV-with-titles-not-working-need-help-with-input/m-p/838894#M36282</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-10-17T03:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: SODA importing CSV with titles not working - need help with input statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SODA-importing-CSV-with-titles-not-working-need-help-with-input/m-p/838902#M36283</link>
      <description>&lt;P&gt;TITLE has a completely different meaning in SAS. A title (set with a &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/lestmtsglobal/p10gcmrmf83iaxn1ilrx4pra969n.htm" target="_blank" rel="noopener"&gt;TITLE Statement&lt;/A&gt;) appears on the top of printed output.&lt;/P&gt;
&lt;P&gt;What you mean are &lt;EM&gt;variable names&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To assist you in creating the correct INFILE and INPUT statements, we need to see your csv file "as is". Open it with a text editor (not with Excel!) and copy/paste several lines (including the header containing the variable names) into a window opened with this button:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54552i914D97BE1B0F21E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 07:10:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SODA-importing-CSV-with-titles-not-working-need-help-with-input/m-p/838902#M36283</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-10-17T07:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: SODA importing CSV with titles not working - need help with input statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SODA-importing-CSV-with-titles-not-working-need-help-with-input/m-p/838994#M36317</link>
      <description>&lt;P&gt;Suggestion: Copy the first 5 lines from the source file. On the forum open a text box with the &amp;lt;/&amp;gt; icon and paste the copied text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We really need to see what the file looks like before reading if the result you get is "wrong".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One very interesting partial variable name is your "Redcap_survey_identifier". A quick web search shows that the REDcap software has the ability to export data as SAS data sets. So perhaps you a spending time in the wrong place and should be looking for the REDCAP tool to export to SAS from it's native form. That is very likely to save a lot of headaches in the long run.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 14:55:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SODA-importing-CSV-with-titles-not-working-need-help-with-input/m-p/838994#M36317</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-10-17T14:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: SODA importing CSV with titles not working - need help with input statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SODA-importing-CSV-with-titles-not-working-need-help-with-input/m-p/839148#M36324</link>
      <description>I have both a .sas and an Excel file on hand, so I could use either. Thank you for the advice and the explanation of what all the parts do! I will try using Proc Import instead and see if that Infile statement helps&lt;BR /&gt;&lt;BR /&gt;And yes, my data export automatically generated some of the import code for me.</description>
      <pubDate>Tue, 18 Oct 2022 10:16:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SODA-importing-CSV-with-titles-not-working-need-help-with-input/m-p/839148#M36324</guid>
      <dc:creator>akimme</dc:creator>
      <dc:date>2022-10-18T10:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: SODA importing CSV with titles not working - need help with input statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SODA-importing-CSV-with-titles-not-working-need-help-with-input/m-p/839149#M36325</link>
      <description>Thanks for the example!</description>
      <pubDate>Tue, 18 Oct 2022 10:17:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SODA-importing-CSV-with-titles-not-working-need-help-with-input/m-p/839149#M36325</guid>
      <dc:creator>akimme</dc:creator>
      <dc:date>2022-10-18T10:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: SODA importing CSV with titles not working - need help with input statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SODA-importing-CSV-with-titles-not-working-need-help-with-input/m-p/839168#M36326</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/396363"&gt;@akimme&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I have both a .sas and an Excel file on hand, so I could use either. Thank you for the advice and the explanation of what all the parts do! I will try using Proc Import instead and see if that Infile statement helps&lt;BR /&gt;&lt;BR /&gt;And yes, my data export automatically generated some of the import code for me.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So your previous code did not mention either a .sas file (which would be a text file with SAS code in it) nor any Excel files (which would be a binary file with the .XLSX extension or the older binary format that uses the .XLS extension).&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you actually have a SAS program file?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then perhaps what you were supposed to do was run the .sas file and use it to read the .csv file and create a SAS dataset.&amp;nbsp; You might have been expected to edit the .sas file to replace the directory where it would look to read the csv file and/or write out a SAS dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that if you started with a .csv file and you accidentally let Excel open the file and re-save it you might have lost information.&amp;nbsp; Excel will do stupid things to CSV files to "help" you.&amp;nbsp; For example if you have an id string with one or two hyphens in it then Excel might think is supposed to be a date and change something like 10-5 into the date October 5th, 2022.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 12:53:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SODA-importing-CSV-with-titles-not-working-need-help-with-input/m-p/839168#M36326</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-10-18T12:53:57Z</dc:date>
    </item>
  </channel>
</rss>

