<?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: can I choose few variable name from multiple text file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/can-I-choose-few-variable-name-from-multiple-text-file/m-p/358974#M84391</link>
    <description>&lt;P&gt;As I mention above, you need to code for your data. &amp;nbsp;There is no magic wand to do your job.&lt;/P&gt;</description>
    <pubDate>Tue, 16 May 2017 11:35:44 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-05-16T11:35:44Z</dc:date>
    <item>
      <title>can I choose few variable name from multiple text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-I-choose-few-variable-name-from-multiple-text-file/m-p/357935#M84077</link>
      <description>&lt;P&gt;I've Multiple text file in one location, I'm able to import them into one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But Few files have 10 Variable/ few of them have 12 Variables/ Few of them are having 4 Variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Variable which I wanted in final dataset present in all of them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;all of the text files have header and I want two of them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can I put those column name somewhere in below code ??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc import datafile="Dir_Name/*.txt" out=work.Metadata dbms=dlm replace;&lt;BR /&gt;delimiter='09'x;&lt;BR /&gt;getnames=yes;&lt;BR /&gt;guessingrows=max;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 15:00:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-I-choose-few-variable-name-from-multiple-text-file/m-p/357935#M84077</guid>
      <dc:creator>atul_desh</dc:creator>
      <dc:date>2017-05-11T15:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: can I choose few variable name from multiple text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-I-choose-few-variable-name-from-multiple-text-file/m-p/357956#M84089</link>
      <description>&lt;P&gt;Well, I would only use proc import to generate the datastep for you. &amp;nbsp;Once you have that code, update it by hand:&lt;/P&gt;
&lt;PRE&gt;data want (keep=the_variable_you_want);
  infile "c:\temp\*.txt" dlm='09'x;
  input the_variable_you_want $ something_else ...;
run;&lt;/PRE&gt;
&lt;P&gt;If the other files don't contain all the varibles then you might get problems, hard to say without seeing the actual data. &amp;nbsp;By similar are those columns completely missing? &amp;nbsp;If so you would need either a program for each import, or you would read the whole of each file line by line and parse out the resulting strings.&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 15:33:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-I-choose-few-variable-name-from-multiple-text-file/m-p/357956#M84089</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-11T15:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: can I choose few variable name from multiple text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-I-choose-few-variable-name-from-multiple-text-file/m-p/358691#M84309</link>
      <description>it is not working..&lt;BR /&gt;&lt;BR /&gt;data want (keep=FileName TotalRecords);&lt;BR /&gt;infile "Path" dsd dlm='09'x;&lt;BR /&gt;input FileName : $50. TotalRecords : $50. ;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;It is taking variable names according to occurence in the file.</description>
      <pubDate>Mon, 15 May 2017 10:50:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-I-choose-few-variable-name-from-multiple-text-file/m-p/358691#M84309</guid>
      <dc:creator>atul_desh</dc:creator>
      <dc:date>2017-05-15T10:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: can I choose few variable name from multiple text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-I-choose-few-variable-name-from-multiple-text-file/m-p/358704#M84312</link>
      <description>&lt;P&gt;You haven't said what "is not working". &amp;nbsp;It will read in the data per the way you have coded it, if its not reading in the data correctly you need to code it per the data??&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2017 11:35:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-I-choose-few-variable-name-from-multiple-text-file/m-p/358704#M84312</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-15T11:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: can I choose few variable name from multiple text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-I-choose-few-variable-name-from-multiple-text-file/m-p/358711#M84315</link>
      <description>&lt;P&gt;If you only want to keep some of the variables you can add the KEEP= dataset option to the output dataset name.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile="Dir_Name/*.txt" dbms=dlm
  out=Metadata(keep=var1 var2 var3) replace
;
  delimiter='09'x;
  getnames=yes;
  guessingrows=max;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that it is probably better to NOT use PROC IMPORT to guess at what is in your data files. &amp;nbsp;Especially if you are going to combine multiple files. &amp;nbsp;The only metadata on your variables that a delimited file contains are the column headers. Otherwise PROC IMPORT has to guess at how to define your variables. &amp;nbsp;So if one file only has short names then it make make the name field too short. &amp;nbsp;Or worse it might define as a number a field that should be character.&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2017 11:54:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-I-choose-few-variable-name-from-multiple-text-file/m-p/358711#M84315</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-05-15T11:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: can I choose few variable name from multiple text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-I-choose-few-variable-name-from-multiple-text-file/m-p/358713#M84317</link>
      <description>Problem is,&lt;BR /&gt;&lt;BR /&gt;1st file is having 12 variable (Var1[Name] to Var12 [Country]) and let say 6th file is having 4 Variable (Var1[Name] to Var4[Country]).&lt;BR /&gt;&lt;BR /&gt;when I'm reading all data Var12[Country] is coming blank for 6th File.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 15 May 2017 12:05:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-I-choose-few-variable-name-from-multiple-text-file/m-p/358713#M84317</guid>
      <dc:creator>atul_desh</dc:creator>
      <dc:date>2017-05-15T12:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: can I choose few variable name from multiple text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-I-choose-few-variable-name-from-multiple-text-file/m-p/358974#M84391</link>
      <description>&lt;P&gt;As I mention above, you need to code for your data. &amp;nbsp;There is no magic wand to do your job.&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 11:35:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-I-choose-few-variable-name-from-multiple-text-file/m-p/358974#M84391</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-16T11:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: can I choose few variable name from multiple text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-I-choose-few-variable-name-from-multiple-text-file/m-p/361117#M85122</link>
      <description>Its done now.. thanks..&lt;BR /&gt;&lt;BR /&gt;I created temperory dataset from all files and then set in the final dataset (keeping only variable what i want).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;%let i=1;&lt;BR /&gt;%do %while (%scan(&amp;amp;fn,&amp;amp;i,' ') ne );&lt;BR /&gt;proc import datafile="&amp;amp;D_IN_reason/%scan(&amp;amp;fn,&amp;amp;i,' ')" out=work.chk_&amp;amp;i dbms=dlm replace;&lt;BR /&gt;delimiter='09'x;&lt;BR /&gt;getnames=yes;&lt;BR /&gt;guessingrows=max;&lt;BR /&gt;run;&lt;BR /&gt;%put %scan(&amp;amp;fn,&amp;amp;i,' ');&lt;BR /&gt;%let i=%eval(&amp;amp;i+1);&lt;BR /&gt;%end;&lt;BR /&gt;run;&lt;BR /&gt;%mend cr_agg_list;&lt;BR /&gt;&lt;BR /&gt;%cr_agg_list;&lt;BR /&gt;&lt;BR /&gt;options symbolgen mlogic mprint;&lt;BR /&gt;&lt;BR /&gt;data fnl_chk;&lt;BR /&gt;attrib filename format=$200.;&lt;BR /&gt;set chk_1-chk_&amp;amp;n_obs (keep=Filename TotalRecords);&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 24 May 2017 09:29:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-I-choose-few-variable-name-from-multiple-text-file/m-p/361117#M85122</guid>
      <dc:creator>atul_desh</dc:creator>
      <dc:date>2017-05-24T09:29:46Z</dc:date>
    </item>
  </channel>
</rss>

