<?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: Creating a macro that creates tables with a CSV file that contains its columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-that-creates-tables-with-a-CSV-file-that/m-p/835177#M330166</link>
    <description>&lt;P&gt;A CSV file does not have any of the items you want.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just look at it what you posed.&amp;nbsp; The only metadata it has is the first line, which most people use as the NAME of the variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The TYPE or storage LENGTH or whether or not you need to use an INFORMAT to read the string from the CSV or not, or whether or not you need to attach a FORMAT to display the values in a way that humans would like to see is NOT provided.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The best you could do is GUESS what values could work.&amp;nbsp; But knowing what the creator of the file intended is not possible.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ask the file creator to provide the metadata you want in a separate file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you must GUESS you could try using PROC IMPORT.&amp;nbsp; Or write your own logic, such as&amp;nbsp;&lt;A href="https://github.com/sasutils/macros/blob/master/csv2ds.sas" target="_blank"&gt;https://github.com/sasutils/macros/blob/master/csv2ds.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Sep 2022 14:31:07 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-09-26T14:31:07Z</dc:date>
    <item>
      <title>Creating a macro that creates tables with a CSV file that contains its columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-that-creates-tables-with-a-CSV-file-that/m-p/835099#M330127</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to create a macro that creates a table which looks up to a CSV file to get its columns with data type, length, format and informat?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CSV file looks like this:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;libname,dataset,colname,datatype,length,format,informat&lt;/P&gt;&lt;P&gt;VEHICLES,CARS,TYPE,char,20,$20.,$20.&lt;/P&gt;&lt;P&gt;VEHICLES,CARS,BRAND,char,30,$30.,$30.&lt;/P&gt;&lt;P&gt;VEHICLES,CARS,MODEL,char,30,$30.,$30.&lt;/P&gt;&lt;P&gt;VEHICLES,CARS,PRICE,num,8,BEST32.,BEST32.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2022 04:10:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-that-creates-tables-with-a-CSV-file-that/m-p/835099#M330127</guid>
      <dc:creator>shindeeen</dc:creator>
      <dc:date>2022-09-26T04:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a macro that creates tables with a CSV file that contains its columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-that-creates-tables-with-a-CSV-file-that/m-p/835125#M330139</link>
      <description>&lt;P&gt;Before you start writing SAS macros implement what you need for a single use case not using macro language. Once that works you can make things dynamic by "macrotizing" your code.&lt;/P&gt;
&lt;P&gt;You certainly can read the .csv as per your screenshot into a SAS table. Once that's done what do you want to do with it?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2022 09:48:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-that-creates-tables-with-a-CSV-file-that/m-p/835125#M330139</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-09-26T09:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a macro that creates tables with a CSV file that contains its columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-that-creates-tables-with-a-CSV-file-that/m-p/835140#M330149</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;option parmcards=x;
filename x temp;
parmcards;
libname,dataset,colname,datatype,length,format,informat
VEHICLES,CARS,TYPE,char,20,$20.,$20.
VEHICLES,CARS,BRAND,char,30,$30.,$30.
VEHICLES,CARS,MODEL,char,30,$30.,$30.
VEHICLES,CARS,PRICE,num,8,BEST32.,BEST32.
;





proc import datafile=x out=dictionary dbms=csv replace;
run;
data _null_;
 set dictionary end=last;
 by libname dataset;
 if _n_=1 then call execute('proc sql;');
 if first.dataset then call execute(cat('create table ',dataset,' ('));
 call execute(cat(colname,' ',datatype,'(',length,') format=',format,' informat=',informat));
 if not last.dataset then call execute(',');
  else call execute(');');
 if last then call execute(';quit;');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Sep 2022 11:49:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-that-creates-tables-with-a-CSV-file-that/m-p/835140#M330149</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-09-26T11:49:57Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a macro that creates tables with a CSV file that contains its columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-that-creates-tables-with-a-CSV-file-that/m-p/835177#M330166</link>
      <description>&lt;P&gt;A CSV file does not have any of the items you want.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just look at it what you posed.&amp;nbsp; The only metadata it has is the first line, which most people use as the NAME of the variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The TYPE or storage LENGTH or whether or not you need to use an INFORMAT to read the string from the CSV or not, or whether or not you need to attach a FORMAT to display the values in a way that humans would like to see is NOT provided.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The best you could do is GUESS what values could work.&amp;nbsp; But knowing what the creator of the file intended is not possible.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ask the file creator to provide the metadata you want in a separate file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you must GUESS you could try using PROC IMPORT.&amp;nbsp; Or write your own logic, such as&amp;nbsp;&lt;A href="https://github.com/sasutils/macros/blob/master/csv2ds.sas" target="_blank"&gt;https://github.com/sasutils/macros/blob/master/csv2ds.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2022 14:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-that-creates-tables-with-a-CSV-file-that/m-p/835177#M330166</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-09-26T14:31:07Z</dc:date>
    </item>
  </channel>
</rss>

