<?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 Macro to convert sas dataset to xpt files in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-convert-sas-dataset-to-xpt-files/m-p/769871#M244152</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 26 datasets in a folder and i wanted to convert all of them into XPT at one go.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can any one help me with a macro ?&lt;/P&gt;</description>
    <pubDate>Thu, 23 Sep 2021 12:05:52 GMT</pubDate>
    <dc:creator>r3570</dc:creator>
    <dc:date>2021-09-23T12:05:52Z</dc:date>
    <item>
      <title>Macro to convert sas dataset to xpt files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-convert-sas-dataset-to-xpt-files/m-p/769871#M244152</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 26 datasets in a folder and i wanted to convert all of them into XPT at one go.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can any one help me with a macro ?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Sep 2021 12:05:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-convert-sas-dataset-to-xpt-files/m-p/769871#M244152</guid>
      <dc:creator>r3570</dc:creator>
      <dc:date>2021-09-23T12:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to convert sas dataset to xpt files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-convert-sas-dataset-to-xpt-files/m-p/769873#M244154</link>
      <description>&lt;P&gt;Have you tried using the XPORT engine in the LIBNAME statement? Here's some documentation:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/movefile/p07no93eh1e7oun1fmp0anvi7k3k.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/movefile/p07no93eh1e7oun1fmp0anvi7k3k.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm assuming you would know how to make a macro out of something like this. There's also this article, but I didn't give it much of a read. There's a section specifically dedicated toward a macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.lexjansen.com/pharmasug/2004/FDACompliance/FC07.pdf" target="_blank"&gt;https://www.lexjansen.com/pharmasug/2004/FDACompliance/FC07.pdf&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 23 Sep 2021 12:09:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-convert-sas-dataset-to-xpt-files/m-p/769873#M244154</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2021-09-23T12:09:43Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to convert sas dataset to xpt files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-convert-sas-dataset-to-xpt-files/m-p/769876#M244157</link>
      <description>&lt;P&gt;Yes i know hoe to convert a single dataset in xpt file using xport in libname statement. but not able to figure out how to convert all the datasets at a time instead of doing it one by one.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Sep 2021 12:13:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-convert-sas-dataset-to-xpt-files/m-p/769876#M244157</guid>
      <dc:creator>r3570</dc:creator>
      <dc:date>2021-09-23T12:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to convert sas dataset to xpt files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-convert-sas-dataset-to-xpt-files/m-p/769895#M244166</link>
      <description>&lt;PRE&gt;/*************一个SAS数据集 转成 一个XPT文件************/
/* path to store xpt file*/
%let path_out= D:\XiaKeShan\my_code\数据管理\转XPT文件\XPT  ;
/* path to address sas dataset*/
%let path_in= D:\XiaKeShan\my_code\数据管理\转XPT文件\SAS  ;


/*transform a sas file into a xpt dataset*/
libname in v9 "&amp;amp;path_in";
data _null_;
rc=filename('x',"&amp;amp;path_in");
did=dopen('x');
do i=1 to dnum(did);
  memname=dread(did,i);
call execute(cat("libname tranfile xport '&amp;amp;path_out\",scan(memname,1,'.'),".xpt';proc copy in=in out=tranfile;select ",scan(memname,1,'.'),";run;"));
end;

run;&lt;/PRE&gt;
&lt;P&gt;Here is V5 version XPT file.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Sep 2021 13:09:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-convert-sas-dataset-to-xpt-files/m-p/769895#M244166</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-09-23T13:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to convert sas dataset to xpt files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-convert-sas-dataset-to-xpt-files/m-p/769897#M244168</link>
      <description>&lt;P&gt;Here is V8 version XPT file .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/*************一个SAS数据集 转成 一个XPT文件************/
/* path to store xpt file*/
%let path_out= D:\XiaKeShan\my_code\数据管理\转XPT文件\XPT  ;
/* path to address sas dataset*/
%let path_in= D:\XiaKeShan\my_code\数据管理\转XPT文件\SAS  ;


/*transform a sas file into a xpt dataset*/
libname in v9 "&amp;amp;path_in";
data _null_;
rc=filename('x',"&amp;amp;path_in");
did=dopen('x');
do i=1 to dnum(did);
  memname=dread(did,i);
call execute(cas("%loc2xpt(libref=in,memlist=",scan(memname,1,'.'),",filespec=&amp;amp;path_out\",scan(memname,1,'.'),".xpt)"));
end;

run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Sep 2021 13:14:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-convert-sas-dataset-to-xpt-files/m-p/769897#M244168</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-09-23T13:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to convert sas dataset to xpt files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-convert-sas-dataset-to-xpt-files/m-p/769955#M244204</link>
      <description>&lt;P&gt;Do you want one XPT file with all 26 datasets in it?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or a separate XPT file for each dataset?&lt;/P&gt;
&lt;P&gt;Or some other combination?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What type of file to you want to create? XPT does not have a fixed meaning.&amp;nbsp; SAS can make CPORT files using PROC CPORT or you can make XPORT files using XPORT engine (for V5 compatible datasets) or the %LOC2XPT() macro for datasets that use features not supported by version 5 SAS datasets.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Sep 2021 15:37:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-convert-sas-dataset-to-xpt-files/m-p/769955#M244204</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-09-23T15:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to convert sas dataset to xpt files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-convert-sas-dataset-to-xpt-files/m-p/769958#M244207</link>
      <description>Hi Tom,&lt;BR /&gt;&lt;BR /&gt;I was able to create a single xpt file which included all the datasets in&lt;BR /&gt;it using proc copy.&lt;BR /&gt;&lt;BR /&gt;Because it is hectic task to write 26 programs for each dataset to convert&lt;BR /&gt;into xpt, I need a macro which creates xpt file separately for each dataset&lt;BR /&gt;in one go.&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Sep 2021 15:56:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-convert-sas-dataset-to-xpt-files/m-p/769958#M244207</guid>
      <dc:creator>r3570</dc:creator>
      <dc:date>2021-09-23T15:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to convert sas dataset to xpt files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-convert-sas-dataset-to-xpt-files/m-p/769964#M244211</link>
      <description>&lt;P&gt;Inputs are probably the libref (or optionally the path) to where to find the datasets and the path for writing the XPT files.&amp;nbsp; Another optional input might be a list of members or logic for how to select the members.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Get the list of members.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=&amp;amp;libref.._all_ noprint out=contents; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Use the list to generate the code to create the XPORT files.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set contents;
  by memname;
  if first.memname;
  call execute(catx(' '
   ,'libname out xport',quote(catx('/',"&amp;amp;targetdir",cats(lowcase(memname),'.xpt'))),';'
   ,'proc copy inlib=',libname,'outlib=out;','select',nliteral(memname),';run;'
  ));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Sep 2021 16:26:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-convert-sas-dataset-to-xpt-files/m-p/769964#M244211</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-09-23T16:26:57Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to convert sas dataset to xpt files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-convert-sas-dataset-to-xpt-files/m-p/770360#M244403</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/382012"&gt;@r3570&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi Tom,&lt;BR /&gt;&lt;BR /&gt;I was able to create a single xpt file which included all the datasets in&lt;BR /&gt;it using proc copy.&lt;BR /&gt;&lt;BR /&gt;Because it is hectic task to write 26 programs for each dataset to convert&lt;BR /&gt;into xpt, I need a macro which creates xpt file separately for each dataset&lt;BR /&gt;in one go.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you can place all the data sets into one file what is the advantage of creating 26 files?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 21:37:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-convert-sas-dataset-to-xpt-files/m-p/770360#M244403</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-09-24T21:37:27Z</dc:date>
    </item>
  </channel>
</rss>

