<?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: Import txt file in a column to a sas data set  with multiple columns in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Import-txt-file-in-a-column-to-a-sas-data-set-with-multiple/m-p/863997#M42537</link>
    <description>&lt;P&gt;The following code makes use of the &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n1rill4udj0tfun1fvce3j401plo.htm" target="_self"&gt;INFILE&lt;/A&gt; and &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n0lrz3gb7m9e4rn137op544ddg0v.htm" target="_self"&gt;INPUT&lt;/A&gt; (list) statements and the INFILE &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n1rill4udj0tfun1fvce3j401plo.htm#n14rjz20kqjrgpn1jpffa0x4i9kl:~:text=DELIMITER%3D%20delimiter(s)" target="_self"&gt;DELIMITER option&lt;/A&gt;&amp;nbsp; (DLM).&lt;BR /&gt;There are good examples in the documentation for further reading&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
	Create sample data
*/

data _null_ ;
	file "have.txt" ;
	infile cards ;
	input ;
	put _infile_ ;
cards ;
Eugene,Basketball
M_52.50_120.33
Vincent,Football
M_43.25_115.15
Chichi,Football
F_35.75_090.50
Videl,Football
F_32.65_085.50
Hanamichi,Basketball
M_69.15_145.55
Alfred,Basketball
M_52.25_135.25
Dennis,Basketball
M_55.15_123.45
Alice,Softball
F_35.30_070.50
Michael,Softball
M_72.43_111.12
Rodrigo,Softball
M_66.15_075.92
Ara,Football
F_92.88_089.99
Karla,Football
F_52.13_078.98
;
run ;

/*
	Read sample data into SAS Dataset
*/

data work.want ;
	
	infile "have.txt" dlm=",_";    /* Point to our source data, set the delimiter to comma and underscore */
	input name $ sport $ ;         /* Read the first line */
	input gender $ weight height ; /* Read the second line */
	output work.want ; 			   /* output to SAS dataset */
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 14 Mar 2023 11:35:08 GMT</pubDate>
    <dc:creator>AMSAS</dc:creator>
    <dc:date>2023-03-14T11:35:08Z</dc:date>
    <item>
      <title>Import txt file in a column to a sas data set  with multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Import-txt-file-in-a-column-to-a-sas-data-set-with-multiple/m-p/863561#M42524</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry I'm a beginner to sas I was hoping you can help me. I was trying to create a data set with the following columns:&lt;/P&gt;&lt;P&gt;name&lt;/P&gt;&lt;P&gt;sport&lt;/P&gt;&lt;P&gt;gender&lt;/P&gt;&lt;P&gt;weight&lt;/P&gt;&lt;P&gt;height&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;from this txt file format:&lt;/P&gt;&lt;P&gt;Eugene,Basketball&lt;BR /&gt;M_52.50_120.33&lt;BR /&gt;Vincent,Football&lt;BR /&gt;M_43.25_115.15&lt;BR /&gt;Chichi,Football&lt;BR /&gt;F_35.75_090.50&lt;BR /&gt;Videl,Football&lt;BR /&gt;F_32.65_085.50&lt;BR /&gt;Hanamichi,Basketball&lt;BR /&gt;M_69.15_145.55&lt;BR /&gt;Alfred,Basketball&lt;BR /&gt;M_52.25_135.25&lt;BR /&gt;Dennis,Basketball&lt;BR /&gt;M_55.15_123.45&lt;BR /&gt;Alice,Softball&lt;BR /&gt;F_35.30_070.50&lt;BR /&gt;Michael,Softball&lt;BR /&gt;M_72.43_111.12&lt;BR /&gt;Rodrigo,Softball&lt;BR /&gt;M_66.15_075.92&lt;BR /&gt;Ara,Football&lt;BR /&gt;F_92.88_089.99&lt;BR /&gt;Karla,Football&lt;BR /&gt;F_52.13_078.98&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was able to easily do the name and sport but having trouble with gender/weight/height since they are in the next row in the txt file.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Mar 2023 00:23:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Import-txt-file-in-a-column-to-a-sas-data-set-with-multiple/m-p/863561#M42524</guid>
      <dc:creator>Machan69</dc:creator>
      <dc:date>2023-03-11T00:23:48Z</dc:date>
    </item>
    <item>
      <title>Re: Import txt file in a column to a sas data set  with multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Import-txt-file-in-a-column-to-a-sas-data-set-with-multiple/m-p/863997#M42537</link>
      <description>&lt;P&gt;The following code makes use of the &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n1rill4udj0tfun1fvce3j401plo.htm" target="_self"&gt;INFILE&lt;/A&gt; and &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n0lrz3gb7m9e4rn137op544ddg0v.htm" target="_self"&gt;INPUT&lt;/A&gt; (list) statements and the INFILE &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n1rill4udj0tfun1fvce3j401plo.htm#n14rjz20kqjrgpn1jpffa0x4i9kl:~:text=DELIMITER%3D%20delimiter(s)" target="_self"&gt;DELIMITER option&lt;/A&gt;&amp;nbsp; (DLM).&lt;BR /&gt;There are good examples in the documentation for further reading&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
	Create sample data
*/

data _null_ ;
	file "have.txt" ;
	infile cards ;
	input ;
	put _infile_ ;
cards ;
Eugene,Basketball
M_52.50_120.33
Vincent,Football
M_43.25_115.15
Chichi,Football
F_35.75_090.50
Videl,Football
F_32.65_085.50
Hanamichi,Basketball
M_69.15_145.55
Alfred,Basketball
M_52.25_135.25
Dennis,Basketball
M_55.15_123.45
Alice,Softball
F_35.30_070.50
Michael,Softball
M_72.43_111.12
Rodrigo,Softball
M_66.15_075.92
Ara,Football
F_92.88_089.99
Karla,Football
F_52.13_078.98
;
run ;

/*
	Read sample data into SAS Dataset
*/

data work.want ;
	
	infile "have.txt" dlm=",_";    /* Point to our source data, set the delimiter to comma and underscore */
	input name $ sport $ ;         /* Read the first line */
	input gender $ weight height ; /* Read the second line */
	output work.want ; 			   /* output to SAS dataset */
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 11:35:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Import-txt-file-in-a-column-to-a-sas-data-set-with-multiple/m-p/863997#M42537</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2023-03-14T11:35:08Z</dc:date>
    </item>
  </channel>
</rss>

