<?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: Define a macro variable for different delimiters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Define-a-macro-variable-for-different-delimiters/m-p/411444#M100589</link>
    <description>&lt;P&gt;Forget your macro, use proc import. You will never be able to reach the flexibility and stability of a SAS-created procedure.&lt;/P&gt;
&lt;P&gt;And when you reach the stage of extracting data step code from proc import logs for repeated execution, stay with the data step code. Involving a macro layer will make your code less maintainable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, OTOH, if you have a clearly defined basic layout of external files (like the fixed-block format typical on mainframes, or a csv with a given set of datatypes - eg coming from a DB system), you could start to write a macro that automatically creates the import data step off a list of field definitions. But at that stage the question of what delimiter to use would long be solved.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do have such support macros. One handles the data transfer from the server (could be Linux or a mainframe), the other reads a single field and sets type, format, length, and detects all missing-value states. So the import procedure looks like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%make_filename(fileref,infile_name,params);

data want;
infile fileref;
%read_field(name,type,length);
%read_field(name,type,length);
....
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This allows me to put an import job side-by-side with the PL-1 include that describes the external file and check if they fit, or where changes are.&lt;/P&gt;
&lt;P&gt;("type" in this context is much more specific than just char or num. Think char, varchar, date, uuid, timestamp, binary, zoned, packed decimal, ....)&lt;/P&gt;</description>
    <pubDate>Wed, 08 Nov 2017 07:51:19 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-11-08T07:51:19Z</dc:date>
    <item>
      <title>Define a macro variable for different delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Define-a-macro-variable-for-different-delimiters/m-p/411421#M100581</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I want to write a&amp;nbsp;macro to import different type of files. Let’s say we have files that are tab-delimited text files as well as CSV files. (“xyz.csv” and “abc.txt”). how do I achieve this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 03:50:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Define-a-macro-variable-for-different-delimiters/m-p/411421#M100581</guid>
      <dc:creator>mv44</dc:creator>
      <dc:date>2017-11-08T03:50:16Z</dc:date>
    </item>
    <item>
      <title>Re: Define a macro variable for different delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Define-a-macro-variable-for-different-delimiters/m-p/411422#M100582</link>
      <description>&lt;P&gt;First figure out all the variations you need and code a manual version. Determine what needs to change for each variation you need and add the corresponding macro variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Given PROC IMPORTs current set up I’m not sure you’re going to gain a whole lot by writing this macro though. Is there some problem you’re trying to solve with this macro?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 04:05:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Define-a-macro-variable-for-different-delimiters/m-p/411422#M100582</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-08T04:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: Define a macro variable for different delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Define-a-macro-variable-for-different-delimiters/m-p/411444#M100589</link>
      <description>&lt;P&gt;Forget your macro, use proc import. You will never be able to reach the flexibility and stability of a SAS-created procedure.&lt;/P&gt;
&lt;P&gt;And when you reach the stage of extracting data step code from proc import logs for repeated execution, stay with the data step code. Involving a macro layer will make your code less maintainable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, OTOH, if you have a clearly defined basic layout of external files (like the fixed-block format typical on mainframes, or a csv with a given set of datatypes - eg coming from a DB system), you could start to write a macro that automatically creates the import data step off a list of field definitions. But at that stage the question of what delimiter to use would long be solved.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do have such support macros. One handles the data transfer from the server (could be Linux or a mainframe), the other reads a single field and sets type, format, length, and detects all missing-value states. So the import procedure looks like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%make_filename(fileref,infile_name,params);

data want;
infile fileref;
%read_field(name,type,length);
%read_field(name,type,length);
....
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This allows me to put an import job side-by-side with the PL-1 include that describes the external file and check if they fit, or where changes are.&lt;/P&gt;
&lt;P&gt;("type" in this context is much more specific than just char or num. Think char, varchar, date, uuid, timestamp, binary, zoned, packed decimal, ....)&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 07:51:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Define-a-macro-variable-for-different-delimiters/m-p/411444#M100589</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-08T07:51:19Z</dc:date>
    </item>
  </channel>
</rss>

