<?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: Using an AUTO call macro %xpt2loc to convert datasets in a library in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-an-AUTO-call-macro-xpt2loc-to-convert-datasets-in-a/m-p/736303#M38671</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32324"&gt;@venkatagopinath&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Tom, First I Thank you for your response. I tried to get the list of transport files using the same code. As you suggested I cant use the code the other way. Can you suggest how to get the list of xpt files or can you suggest how to convert all the xptfiles at one go. I used %xpt2loc macro to convert single xpt file to sas dataset.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are you doing this task once?&amp;nbsp; Then just copy and paste the filenames into the program editor and convert the list of names into macro calls.&lt;/P&gt;
&lt;P&gt;Otherwise use any of the many methods you can find in answers to multiple questions here to build the list of filenames.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data files ;
  infile "dir c:\mydir\*.xpt /b" pipe truncover ;
  input filename $256.;
  filename = cats('c:\mydir\',filename);
run;
data files ;
  infile "ls -d /mydir/*.xpt" pipe truncover ;
  input filename $256.;
run;
data files;
  length filename $256 ;
  rc=filename('dir','c:\mydir\');
  did=dopen('dir');
  do i=1 to dnum(did);
    filename=cats('c:\mydir\',dread(did,i));
    if scan(filename,-1,'.')='xpt' then output;
  end;
  rc=dclose(did);
  rc=filename('dir');
  keep filename;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 22 Apr 2021 01:51:13 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-04-22T01:51:13Z</dc:date>
    <item>
      <title>Using an AUTO call macro %xpt2loc to convert datasets in a library</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-an-AUTO-call-macro-xpt2loc-to-convert-datasets-in-a/m-p/736065#M38650</link>
      <description>&lt;P&gt;I used the auto call program %loc2xpt to convert sas datasets to XPT&amp;nbsp; using the below code.&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table sdtmDomains as&lt;BR /&gt;select libname&lt;BR /&gt;,memname&lt;BR /&gt;from dictionary.tables&lt;BR /&gt;where libname eq 'SDTM'&lt;BR /&gt;order by memname;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;set sdtmDomains end=eof;&lt;BR /&gt;call symput('domain_' || strip(put(_n_,2.))&lt;BR /&gt;,strip(lowcase(memname))&lt;BR /&gt;);&lt;BR /&gt;if eof then&lt;BR /&gt;call symput('domainCnt',strip(put(_n_,2.)));&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%macro xpt;&lt;BR /&gt;%do idx=1 %to &amp;amp;domainCnt;&lt;/P&gt;&lt;P&gt;filename xptfile "c:\public\sdtm\&amp;amp;&amp;amp;domain_&amp;amp;idx...xpt";&lt;BR /&gt;%loc2xpt(libref=sdtm&lt;BR /&gt;,memlist=&amp;amp;&amp;amp;domain_&amp;amp;idx&lt;BR /&gt;,filespec=xptfile&lt;BR /&gt;);&lt;BR /&gt;%end;&lt;BR /&gt;%mend xpt;&lt;BR /&gt;%xpt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to change the above code to use with another auto call macro %xpt2loc to convert the xpt datasets back to sas datasets and I am ending with errors.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%xpt2loc(libref=work, memlist=Thisisalongdatasetname, filespec='c:\trans.v9xpt' );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I susbstituted the above auto call code with %xpt2loc macro call and its not working. Any help on this issue. I have to convert 100 xpt datasets using the %xpt2loc macro.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 18:22:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-an-AUTO-call-macro-xpt2loc-to-convert-datasets-in-a/m-p/736065#M38650</guid>
      <dc:creator>venkatagopinath</dc:creator>
      <dc:date>2021-04-21T18:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Using an AUTO call macro %xpt2loc to convert datasets in a library</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-an-AUTO-call-macro-xpt2loc-to-convert-datasets-in-a/m-p/736104#M38655</link>
      <description>&lt;P&gt;Before using a macro to generate code (or any other code generation technique) make sure you know what code you want to generate.&amp;nbsp; Show an example of a working call to %XPT2LOC() for one of your existing transport files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the header of the macro definition you probably only want to supply the LIBREF and the FILESPEC parameters.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%*-------------------------------------------------------------------*;
%* The xpt2loc macro is used to convert a transport file into local  *;
%* SAS data set representation. The parameters are:                  *;
%*                                                                   *;
%* libref=          indicates the libref where the members will be   *;
%*                  written. The default is WORK.                    *;
%* memlist=         indicates the list of members in the library     *;
%*                  that are to be converted. The default is that    *;
%*                  all members will be converted.                   *;
%* filespec=        gives a fileref (unquoted) or a file path        *;
%*                  (quoted) where the transport file resides        *;
%*                  written. There is no default.                    *;
%*                                                                   *;
%* This macro should be able to handle V5 transport files written by *;
%* the XPORT engine. It should also handle V8 extended transport     *;
%* files written by the companion loc2xpt macro.                     *;
%*-------------------------------------------------------------------*;

%macro xpt2loc(libref=work,memlist=_all_,filespec=);
...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Where are you getting the list of transport files?&amp;nbsp; You cannot use the same method you used for making the list of datasets when going the other way.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 19:53:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-an-AUTO-call-macro-xpt2loc-to-convert-datasets-in-a/m-p/736104#M38655</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-21T19:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: Using an AUTO call macro %xpt2loc to convert datasets in a library</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-an-AUTO-call-macro-xpt2loc-to-convert-datasets-in-a/m-p/736239#M38657</link>
      <description>&lt;P&gt;Hi Tom, First I Thank you for your response. I tried to get the list of transport files using the same code. As you suggested I cant use the code the other way. Can you suggest how to get the list of xpt files or can you suggest how to convert all the xptfiles at one go. I used %xpt2loc macro to convert single xpt file to sas dataset.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 20:14:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-an-AUTO-call-macro-xpt2loc-to-convert-datasets-in-a/m-p/736239#M38657</guid>
      <dc:creator>venkatagopinath</dc:creator>
      <dc:date>2021-04-21T20:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: Using an AUTO call macro %xpt2loc to convert datasets in a library</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-an-AUTO-call-macro-xpt2loc-to-convert-datasets-in-a/m-p/736242#M38659</link>
      <description>&lt;P&gt;to be more specific i used the below code to get the list of transport files and for converison. which is giving errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table sdtmDomains as&lt;BR /&gt;select libname&lt;BR /&gt;,memname&lt;BR /&gt;from dictionary.tables&lt;BR /&gt;where libname eq 'SDTM'&lt;BR /&gt;order by memname;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;set sdtmDomains end=eof;&lt;BR /&gt;call symput('domain_' || strip(put(_n_,2.))&lt;BR /&gt;,strip(lowcase(memname))&lt;BR /&gt;);&lt;BR /&gt;if eof then&lt;BR /&gt;call symput('domainCnt',strip(put(_n_,2.)));&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%macro xpt;&lt;BR /&gt;%do idx=1 %to &amp;amp;domainCnt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;filename xptfile "c:\public\sdtm\&amp;amp;&amp;amp;domain_&amp;amp;idx...xpt";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%xpt2loc(libref=sdtm, memlist= &amp;amp;&amp;amp;domain_&amp;amp;idx , filespec=xptfile);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%end;&lt;BR /&gt;%mend xpt;&lt;BR /&gt;%xpt&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 20:27:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-an-AUTO-call-macro-xpt2loc-to-convert-datasets-in-a/m-p/736242#M38659</guid>
      <dc:creator>venkatagopinath</dc:creator>
      <dc:date>2021-04-21T20:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: Using an AUTO call macro %xpt2loc to convert datasets in a library</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-an-AUTO-call-macro-xpt2loc-to-convert-datasets-in-a/m-p/736245#M38660</link>
      <description>&lt;P&gt;I really doubt that transport files are going to appear in dictionary.tables. Since your stated goal is to transform the transport files to data sets how can they appear in the dictionary.tables, which contains information about data sets and views but not external files such as XPT. The only possible connection is if you have xpt files whose names sort of match existing data sets which seems most likely to only replace existing data sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 20:36:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-an-AUTO-call-macro-xpt2loc-to-convert-datasets-in-a/m-p/736245#M38660</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-21T20:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using an AUTO call macro %xpt2loc to convert datasets in a library</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-an-AUTO-call-macro-xpt2loc-to-convert-datasets-in-a/m-p/736260#M38663</link>
      <description>&lt;P&gt;Hi ballardw,&lt;/P&gt;&lt;P&gt;Thanks for your repsonse. I agree with you transport files are not displayed even when i write proc datasets statement. Can you give more explanation on the possible connection. do you mean my xpt files and sas datasets should have names?&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 21:23:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-an-AUTO-call-macro-xpt2loc-to-convert-datasets-in-a/m-p/736260#M38663</guid>
      <dc:creator>venkatagopinath</dc:creator>
      <dc:date>2021-04-21T21:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using an AUTO call macro %xpt2loc to convert datasets in a library</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-an-AUTO-call-macro-xpt2loc-to-convert-datasets-in-a/m-p/736279#M38668</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32324"&gt;@venkatagopinath&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi ballardw,&lt;/P&gt;
&lt;P&gt;Thanks for your repsonse. I agree with you transport files are not displayed even when i write proc datasets statement. Can you give more explanation on the possible connection. do you mean my xpt files and sas datasets should have names?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;XPT files are text files in a specific format so that different operating system versions of SAS could interchange data. Which was pretty critical 30 years ago when almost no network connectivity allowed machines to talk to each other. So a standard file format is read by any version of SAS and you can create a new data set in the local SAS version.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your "driver" program to call the macro would have to get a list of XPT files. There are lots of examples on the forum using Filename with PIPE to use the operating system file list tools to get file names into a data set.&lt;/P&gt;
&lt;P&gt;Here is just one to get CSV files.: &lt;A href="https://communities.sas.com/t5/SAS-Programming/Importing-csv-files-from-local-folder-in-work/m-p/550034" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Importing-csv-files-from-local-folder-in-work/m-p/550034&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;you will want to read some of the discussion and make sure that your variable to hold the file names is long enough for the entire path you need to search and replace CSV with XPT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With Windows you might want to use the /S switch on the DIR command to search for subfolders if your XPT files are in multiple folders under a specific starting named folder.&lt;/P&gt;
&lt;P&gt;Then you would want to make sure the full filename, from the drive letter to the XPT is in file name variable to use with the macro.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 22:32:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-an-AUTO-call-macro-xpt2loc-to-convert-datasets-in-a/m-p/736279#M38668</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-21T22:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using an AUTO call macro %xpt2loc to convert datasets in a library</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-an-AUTO-call-macro-xpt2loc-to-convert-datasets-in-a/m-p/736280#M38669</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32324"&gt;@venkatagopinath&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I understand right then you can make things work for a single .xpt. You now need just a way to implement so you can execute dynamically for a list of .xpt&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first step in your code attempts to create such a list of .xpt files for further processing. As you already understand .xpt files are from a SAS perspective external files and though not added to the SAS dictionary for tables.&lt;/P&gt;
&lt;P&gt;Use any logic that list files in a folder. One common method is to use a filename pipe with &lt;EM&gt;dir&lt;/EM&gt; (for Windows) or &lt;EM&gt;ls&lt;/EM&gt; (for Unix/Linux) to create such a list. This approach requires system option XCMD set (default is NOXCMD).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have to deal with NOXCDM then there are also SAS code only ways to create a directory listing. You could use sample code from the SAS Docu found &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n0js70lrkxo6uvn1fl4a5aafnlgt" target="_self"&gt;here&lt;/A&gt; as a starting point. ...or may-be some "Googling" brings up something that's even closer to what you need.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 22:45:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-an-AUTO-call-macro-xpt2loc-to-convert-datasets-in-a/m-p/736280#M38669</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-21T22:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using an AUTO call macro %xpt2loc to convert datasets in a library</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-an-AUTO-call-macro-xpt2loc-to-convert-datasets-in-a/m-p/736303#M38671</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32324"&gt;@venkatagopinath&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Tom, First I Thank you for your response. I tried to get the list of transport files using the same code. As you suggested I cant use the code the other way. Can you suggest how to get the list of xpt files or can you suggest how to convert all the xptfiles at one go. I used %xpt2loc macro to convert single xpt file to sas dataset.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are you doing this task once?&amp;nbsp; Then just copy and paste the filenames into the program editor and convert the list of names into macro calls.&lt;/P&gt;
&lt;P&gt;Otherwise use any of the many methods you can find in answers to multiple questions here to build the list of filenames.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data files ;
  infile "dir c:\mydir\*.xpt /b" pipe truncover ;
  input filename $256.;
  filename = cats('c:\mydir\',filename);
run;
data files ;
  infile "ls -d /mydir/*.xpt" pipe truncover ;
  input filename $256.;
run;
data files;
  length filename $256 ;
  rc=filename('dir','c:\mydir\');
  did=dopen('dir');
  do i=1 to dnum(did);
    filename=cats('c:\mydir\',dread(did,i));
    if scan(filename,-1,'.')='xpt' then output;
  end;
  rc=dclose(did);
  rc=filename('dir');
  keep filename;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Apr 2021 01:51:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-an-AUTO-call-macro-xpt2loc-to-convert-datasets-in-a/m-p/736303#M38671</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-22T01:51:13Z</dc:date>
    </item>
  </channel>
</rss>

