<?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 adding count variable to import all csv file from a folder in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/adding-count-variable-to-import-all-csv-file-from-a-folder/m-p/395607#M95450</link>
    <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;I follow this below code to import all CSV file from a folder.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/Import_all_files_one_type" target="_blank" rel="nofollow noopener noreferrer noopener noreferrer"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/Import_all_files_one_type&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first step is to create a list, then run a macro through the list to create test1, test2... file&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For each file, say test2, i would like to add a variable name order, which will take value 2.&lt;/P&gt;
&lt;P&gt;So when I comebine all data, I know the original data of a given row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help is very much appreciate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HC&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Sep 2017 16:17:47 GMT</pubDate>
    <dc:creator>hhchenfx</dc:creator>
    <dc:date>2017-09-13T16:17:47Z</dc:date>
    <item>
      <title>adding count variable to import all csv file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/adding-count-variable-to-import-all-csv-file-from-a-folder/m-p/395607#M95450</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;I follow this below code to import all CSV file from a folder.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/Import_all_files_one_type" target="_blank" rel="nofollow noopener noreferrer noopener noreferrer"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/Import_all_files_one_type&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first step is to create a list, then run a macro through the list to create test1, test2... file&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For each file, say test2, i would like to add a variable name order, which will take value 2.&lt;/P&gt;
&lt;P&gt;So when I comebine all data, I know the original data of a given row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help is very much appreciate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HC&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 16:17:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/adding-count-variable-to-import-all-csv-file-from-a-folder/m-p/395607#M95450</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2017-09-13T16:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: adding count variable to import all csv file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/adding-count-variable-to-import-all-csv-file-from-a-folder/m-p/395613#M95452</link>
      <description>&lt;P&gt;You need to provide more context as all you linked to was a program that is pretty generic.&lt;/P&gt;
&lt;P&gt;If you want to add a new variable to a dataset that you create using PROC IMPORT like that program does then you will need to use a new step. Something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test2 ;
  order=2;
  set test2 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So if you have a macro variable named ORDER that was driving the process&amp;nbsp;and used to generate the dataset names then perhaps that code in the middle of a macro might look like;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test&amp;amp;order ;
  order=&amp;amp;order;
  set test&amp;amp;order ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you already have a series of dataset and you want to combine them and add a variable to indicate where a particular observation came from look at using the INDSNAME option on the SET statement. &amp;nbsp;So this code will combine 200 datasets into one and make a new variable named MEMBERNAME that has the dataset name.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data all_tables ;
   length dsname $200 membername $32  ;
   set test1 - test200 indsname=dsname;
   membername=scan(dsname,-1,'.');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Sep 2017 16:25:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/adding-count-variable-to-import-all-csv-file-from-a-folder/m-p/395613#M95452</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-09-13T16:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: adding count variable to import all csv file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/adding-count-variable-to-import-all-csv-file-from-a-folder/m-p/395830#M95531</link>
      <description>&lt;P&gt;Thank you so much as always, Tom.&lt;/P&gt;
&lt;P&gt;HC&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2017 01:13:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/adding-count-variable-to-import-all-csv-file-from-a-folder/m-p/395830#M95531</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2017-09-14T01:13:51Z</dc:date>
    </item>
  </channel>
</rss>

