<?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 to SAS Dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789302#M252553</link>
    <description>Is the AE file a public file? If so, can you share the original source? Seems like a corrupt download possibly. &lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 10 Jan 2022 16:56:32 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-01-10T16:56:32Z</dc:date>
    <item>
      <title>Convert XPT to SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789295#M252547</link>
      <description>&lt;P&gt;Using SAS 9.4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have received 17 SAS transport files and cannot seem to find code for how to convert these files to a SAS dataset. I have tried the code below with no success to convert one xpt, would anyone know what I am doing incorrectly? Thank you&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;libname sasfile “path\IHMR”;&lt;/P&gt;
&lt;P&gt;libname xptfile xport “path\IHMR\ae.xpt” access=readonly;&lt;/P&gt;
&lt;P&gt;proc copy inlib=xptfile outlib=sasfile;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 16:44:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789295#M252547</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2022-01-10T16:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: Convert XPT to SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789297#M252549</link>
      <description>&lt;P&gt;Code looks correct. What errors do you get?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194348"&gt;@GS2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Using SAS 9.4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have received 17 SAS transport files and cannot seem to find code for how to convert these files to a SAS dataset. I have tried the code below with no success to convert one xpt, would anyone know what I am doing incorrectly? Thank you&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;libname sasfile “path\IHMR”;&lt;/P&gt;
&lt;P&gt;libname xptfile xport “path\IHMR\ae.xpt” access=readonly;&lt;/P&gt;
&lt;P&gt;proc copy inlib=xptfile outlib=sasfile;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 16:47:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789297#M252549</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-10T16:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: Convert XPT to SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789298#M252550</link>
      <description>&lt;P&gt;Show us the log for all the code you have shown.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 16:52:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789298#M252550</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-01-10T16:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: Convert XPT to SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789300#M252552</link>
      <description>&lt;PRE&gt;NOTE: SAS initialization used:
      real time           40.26 seconds
      cpu time            3.56 seconds

1    libname sasfile 'path\IHMR';
NOTE: Libref SASFILE was successfully assigned as follows:
      Engine:        V9
      Physical Name: path\IHMR
2    libname xptfile xport 'path\IHMR\ae.xpt' access=readonly;
NOTE: Libref XPTFILE was successfully assigned as follows:
      Engine:        XPORT
      Physical Name: path\IHMR\ae.xpt
3    proc copy inlib=xptfile outlib=sasfile;
NOTE: Writing HTML Body file: sashtml.htm
4    run;

NOTE: Input library XPTFILE is sequential.
ERROR: File XPTFILE.ALL. is not a SAS data set.
NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE COPY used (Total process time):
      real time           8.18 seconds
      cpu time            0.57 seconds

NOTE: The SAS System stopped processing this step because of errors.
&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Jan 2022 16:55:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789300#M252552</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2022-01-10T16:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: Convert XPT to SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789302#M252553</link>
      <description>Is the AE file a public file? If so, can you share the original source? Seems like a corrupt download possibly. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Jan 2022 16:56:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789302#M252553</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-10T16:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: Convert XPT to SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789303#M252554</link>
      <description>My log with the errors is posted above</description>
      <pubDate>Mon, 10 Jan 2022 16:58:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789303#M252554</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2022-01-10T16:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Convert XPT to SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789304#M252555</link>
      <description>Unfortunately it is not a public file. However, It was a file I was given. So, potentially the person who sent the file did not convert the dataset to an xpt file correctly?</description>
      <pubDate>Mon, 10 Jan 2022 17:03:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789304#M252555</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2022-01-10T17:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: Convert XPT to SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789307#M252556</link>
      <description>&lt;P&gt;Are you sure the file is an XPORT format file?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Look at the top of the file to see:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile 'path\IHMR\ae.xpt' lrecl=80 recfm=f obs=5;
  input;
  list;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 17:27:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789307#M252556</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-10T17:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: Convert XPT to SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789309#M252557</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;5    data _null_;
6      infile 'path\IHMR\Data_112921\ae.xpt'
6  ! lrecl=80 recfm=f obs=5;
7      input;
8      list;
9    run;

NOTE: The infile 'path\IHMR\Data_112921\ae.xpt' is:
      Filename=path\IHMR \Data_112921\ae.xpt,
      RECFM=F,LRECL=80,File Size (bytes)=240,
      Last Modified=07Jan2022:14:22:53,
      Create Time=05Jan2022:09:18:36

RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9--
1         HEADER RECORD*******LIBV8   HEADER RECORD!!!!!!!000000000000000000000000000000

2   CHAR  SAS     SAS     SASLIB  9.1     WIN.....                        07JAN22:14:22:54
    ZONE  54522222545222225454442232322222544000002222222222222222222222223344433333333333
    NUMR  3130000031300000313C92009E10000079E0000000000000000000000000000007A1E22A14A22A54
3         07JAN22:14:22:54
NOTE: 3 records were read from the infile 'path\IHMR\Data_112921\ae.xpt'.
NOTE: DATA statement used (Total process time):
      real time           0.25 seconds
      cpu time            0.10 seconds
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Above is the log after running the code&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 17:39:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789309#M252557</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2022-01-10T17:39:00Z</dc:date>
    </item>
    <item>
      <title>Re: Convert XPT to SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789310#M252558</link>
      <description>&lt;P&gt;So you don't have an XPORT file.&amp;nbsp; That format only supports SAS V5 transport files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead you have the modified format that requires you use to SAS supplied macros to convert.&amp;nbsp; For some reason rather than generating a new engine that could work with longer names and longer variables they created SAS macros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use %XPT2LOC to convert your file into SAS dataset(s).&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/movefile/p1tp8gighlgeifn173i6kzw2w3bu.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/movefile/p1tp8gighlgeifn173i6kzw2w3bu.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 17:50:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789310#M252558</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-10T17:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: Convert XPT to SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789311#M252559</link>
      <description>&lt;P&gt;Your file appears truncated.&lt;/P&gt;
&lt;P&gt;After the first three records you should see HEADER records to indicate the start of an actual dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's make an example transport file using the macros and see what the beginning of it looks like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename xxx temp;
%loc2xpt(libref=sashelp,memlist=class,filespec=xxx,format=V9);
data _null_;
  infile xxx recfm=f lrecl=80 obs=7;
  input;
  list;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
1         HEADER RECORD*******LIBV8   HEADER RECORD!!!!!!!000000000000000000000000000000

2   CHAR  SAS     SAS     SASLIB  9.1     WIN.....                        10JAN22:12:58:52
    ZONE  54522222545222225454442232322222544000002222222222222222222222223344433333333333
    NUMR  3130000031300000313C92009E10000079E0000000000000000000000000000010A1E22A12A58A52
3         10JAN22:12:58:52
4         HEADER RECORD*******MEMBV8  HEADER RECORD!!!!!!!000000000000000001600000000140
5         HEADER RECORD*******DSCPTV8 HEADER RECORD!!!!!!!000000000000000000000000000000

6   CHAR  SAS     CLASS                           SASDATA 9.1     WIN.....10JAN22:12:58:52
    ZONE  54522222444552222222222222222222222222225454454232322222544000003344433333333333
    NUMR  313000003C133000000000000000000000000000313414109E10000079E0000010A1E22A12A58A52
7         10JAN22:12:58:52                Student Data
&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Jan 2022 18:01:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789311#M252559</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-10T18:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: Convert XPT to SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789313#M252561</link>
      <description>&lt;P&gt;1. Try reading in&lt;A href="https://wwwn.cdc.gov/nchs/nhanes/search/datapage.aspx?Component=Demographics&amp;amp;CycleBeginYear=2017" target="_self"&gt; another XPT file&lt;/A&gt; and see if that works for you. If not, you have an issue with SAS. The link to an example NHANES xpt file is there for you.&lt;/P&gt;
&lt;P&gt;2. If it works, try redownloading the file you were sent by your colleague and uncompress it (if zipped). If that fails, then you have a bad file and I'd ask whomeever sent it to you to recreate the file and resend it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 18:17:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789313#M252561</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-10T18:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: Convert XPT to SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789314#M252562</link>
      <description>Demo_J runs like it is supposed to with my original code. I tried a new file and downloaded the same file again and both do not work. So, likely this is an error on the part of the sender? Thank you</description>
      <pubDate>Mon, 10 Jan 2022 18:36:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789314#M252562</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2022-01-10T18:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: Convert XPT to SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789324#M252565</link>
      <description>&lt;P&gt;Your original code will not work on V8/V9 versions of transport files, which is what your truncated ae.xpt file was.&lt;/P&gt;
&lt;P&gt;You need to use the %XPT2LOC() macro to convert instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname sasfile "path\IHMR";
%xpt2loc(libref=sasfile,filespec="path\IHMR\ae.xpt");
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Jan 2022 19:08:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Dataset/m-p/789324#M252565</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-10T19:08:04Z</dc:date>
    </item>
  </channel>
</rss>

