<?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: convert xpt files to sas datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/860132#M339814</link>
    <description>As &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; pointed out. either the fold you stored xpt file does not exist ,or you don't have permission to enter it.</description>
    <pubDate>Wed, 22 Feb 2023 11:49:34 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2023-02-22T11:49:34Z</dc:date>
    <item>
      <title>convert xpt files to sas datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/744565#M233269</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a question about converting xpt files to sas datasets. I have a folder containing a&amp;nbsp; couple of xpt files. now I want to convert them to sas datasets. Of course I can use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc copy inlib=  outlib= ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to convert one by one. However, if I have hundreds of xpt files, it's obviously time-consuming. So I am thinking to do this job with a macro or a loop. But I don't know how to do it. Any&amp;nbsp; suggestion is welcome. Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;xpt files saved under&amp;nbsp;&lt;/P&gt;
&lt;P&gt;libname xfolder "C:\statdata\onco\datasets\sdtmdata\validation\xpt_new";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output datasets want to save under&lt;/P&gt;
&lt;P&gt;libname sfolder "C:\statdata\onco\datasets\sdtmdata\output";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 29 May 2021 00:14:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/744565#M233269</guid>
      <dc:creator>lc7033907</dc:creator>
      <dc:date>2021-05-29T00:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: convert xpt files to sas datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/744574#M233272</link>
      <description>&lt;P&gt;Hello&lt;BR /&gt;Please have a look here&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Datasets/td-p/97872" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Datasets/td-p/97872&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;There is an elegant solution relevant to your needs in the post by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 29 May 2021 01:49:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/744574#M233272</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2021-05-29T01:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: convert xpt files to sas datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/744606#M233283</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
/* path to address xpt file*/
%let path_in= D:\XiaKeShan\my_code\数据管理\转XPT文件\XPT  ;
/* path to store sas dataset*/
%let path_out= D:\XiaKeShan\my_code\数据管理\转XPT文件\XPT  ;


/*transform a xpt file into a sas dataaset*/
libname out v9 "&amp;amp;path_out";
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_in\",strip(memname),"';proc copy in=tranfile out=out ;run;"));
end;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 29 May 2021 11:19:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/744606#M233283</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-05-29T11:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: convert xpt files to sas datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/744637#M233297</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/131732"&gt;@Sajid01&lt;/a&gt;&amp;nbsp;Thanks. It's really helpful.&lt;/P&gt;</description>
      <pubDate>Sun, 30 May 2021 03:04:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/744637#M233297</guid>
      <dc:creator>lc7033907</dc:creator>
      <dc:date>2021-05-30T03:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: convert xpt files to sas datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/744638#M233298</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;I understand your ideas. But I found your path_in and path_out are exactly the same, so I get a little bit confused. As I stated libraries for xpt files and sas datasets that I want to save, should I put&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let path_in=&lt;SPAN&gt;C:\statdata\onco\datasets\sdtmdata\validation\xpt_new;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;%let path_out=&lt;SPAN&gt;C:\statdata\onco\datasets\sdtmdata\output;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Sun, 30 May 2021 03:13:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/744638#M233298</guid>
      <dc:creator>lc7033907</dc:creator>
      <dc:date>2021-05-30T03:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: convert xpt files to sas datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/744642#M233301</link>
      <description>Sure. No problem. if you want store sas dataset into another directory .</description>
      <pubDate>Sun, 30 May 2021 09:42:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/744642#M233301</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-05-30T09:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: convert xpt files to sas datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/744703#M233335</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp; thanks. I understand now.&lt;/P&gt;</description>
      <pubDate>Sun, 30 May 2021 21:45:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/744703#M233335</guid>
      <dc:creator>lc7033907</dc:creator>
      <dc:date>2021-05-30T21:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: convert xpt files to sas datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/838433#M331504</link>
      <description>&lt;P&gt;Hi:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tested because I also need to convert multiple xpt files to sas datasets. it works perfectly. thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/******************************************************************************************
     READ MULTIPLE XPT FILE IN ONE DIRECTORY AND SAVE INTO EXCEL FILES
*****************************************************************************************/					
/* PATH TO ADDRESS XPT FILE-ALL XPT FILES ARE STORE IN XPTFILE(---ONLY XPT FILES IN THIS DESIGNATED FOLDER---) */
%let path_in= C:\xptfile;
/* PATH TO STORE SAS DATASET-NEED CREATE THE FOLDER-OUTFOLDER */
%let path_out= C:\outfolder;

/*TRANSFORM MUL XPT FILES INTO A SAS DATAASETS*/
/*CREATE A LIBNAME FOR OUTPUT FOLDER SAS DATASET*/
libname out v9 "&amp;amp;path_out";

data _null_;
/*OPEN EACH XPT FILE AND GET THE TOTAL NUMBER OF XPT FILES -&amp;amp;DID*/
		rc=filename('x',"&amp;amp;path_in");
		did=dopen('x');

/*USE CALL EXECUTE  AND DO LOOP TO READ IN XPT FILES */
		do i=1 to dnum(did);
		  memname=dread(did,i);
		  call execute(cat("libname tranfile xport '&amp;amp;path_in\",strip(memname),"';proc copy in=tranfile out=out ;run;"));
		end;

run;
&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Oct 2022 16:17:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/838433#M331504</guid>
      <dc:creator>purpleclothlady</dc:creator>
      <dc:date>2022-10-13T16:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: convert xpt files to sas datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/860020#M339751</link>
      <description>&lt;P&gt;I am trying to use this solution. But I am finding below error in do loop. Can you help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3280 do i=1 to dnum(did);&lt;BR /&gt;3281 memname=dread(did,i);&lt;BR /&gt;3282 call execute(cat("libname tranfile xport&lt;BR /&gt;3282! '&amp;amp;path_in\",strip(memname),"';proc copy in=tranfile out=out ;run;"));&lt;BR /&gt;3283 end;&lt;BR /&gt;3284&lt;BR /&gt;3285 run;&lt;/P&gt;&lt;P&gt;NOTE: Argument 1 to function DNUM(0) at line 3280 column 19 is invalid.&lt;BR /&gt;ERROR: Invalid DO loop control information, either the INITIAL or TO&lt;BR /&gt;expression is missing or the BY expression is missing, zero, or&lt;BR /&gt;invalid.&lt;BR /&gt;rc=0 did=0 i=1 memname= _ERROR_=1 _N_=1&lt;BR /&gt;NOTE: Mathematical operations could not be performed at the following&lt;BR /&gt;places. The results of the operations have been set to missing&lt;BR /&gt;values.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 21:07:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/860020#M339751</guid>
      <dc:creator>NP2212</dc:creator>
      <dc:date>2023-02-21T21:07:13Z</dc:date>
    </item>
    <item>
      <title>Re: convert xpt files to sas datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/860031#M339757</link>
      <description>&lt;P&gt;You are not showing the actual cause of the error.&amp;nbsp; The error is saying that using a directory handle of zero is invalid with the DNUM() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming that you created the DID variable by using the DOPEN() statement that means that the open failed. So the path you tried to read does not exist, or is not actually a directory, or perhaps it is a directory but you do not have permission to read it.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 22:02:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/860031#M339757</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-21T22:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: convert xpt files to sas datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/860132#M339814</link>
      <description>As &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; pointed out. either the fold you stored xpt file does not exist ,or you don't have permission to enter it.</description>
      <pubDate>Wed, 22 Feb 2023 11:49:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-xpt-files-to-sas-datasets/m-p/860132#M339814</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-02-22T11:49:34Z</dc:date>
    </item>
  </channel>
</rss>

