<?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: error message with converting sas data to xpt format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/error-message-with-converting-sas-data-to-xpt-format/m-p/951001#M371818</link>
    <description>&lt;P&gt;So the issue does not appear to be the conversion to XPORT files. Instead it is the attempt to force WINDOWS to use a UNC path as the current working directory.&amp;nbsp; That is not possible.&amp;nbsp; And not needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are plenty of ways to get the list of files in a directory.&amp;nbsp; You can even use pure SAS code.&amp;nbsp; See&amp;nbsp;&lt;A href="https://github.com/sasutils/macros/blob/master/dirtree.sas" target="_self"&gt;%dirtree()&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you could just make a small change to your current code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   infile "dir /b &amp;amp;sasdir\*.sas7bdat" pipe truncover;
   input fname $200. ;
   call symputx(cats('f',_n_),scan(fname,1,'.'));
   call symputx("fcnt",_n_);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also you are passing () around the value of the target directory in your macro call, which will cause the wrong filenames to be generated.&amp;nbsp; Did you intend to wrap that path in a %STR() macro function call also?&amp;nbsp; Note that the %STR() is not needed for the example paths you are showing since they do not include any macro triggers that need masking.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%sas2xpt
(sasdir=\\itsu.com\Analysis\Working_Folder\ads
,xptdir=\\itsu.com\Analysis\Working_Folder\ads
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 21:34:51 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-11-16T21:34:51Z</dc:date>
    <item>
      <title>error message with converting sas data to xpt format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/error-message-with-converting-sas-data-to-xpt-format/m-p/950988#M371814</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using an existing code template to convert sas data to xpt; however, when i run the code i get an error message.&amp;nbsp; Please help!!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;error message:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HitmonTran_0-1731734660944.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/102283iE0CCE0300A28CA42/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HitmonTran_0-1731734660944.png" alt="HitmonTran_0-1731734660944.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sas code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%macro sas2xpt (sasdir=, xptdir=);

x "cd &amp;amp;sasdir";
filename files pipe "dir /b *.sas7bdat";

data _null_;
   infile files;
   length fname $ 200;
   retain i 0;
   input fname;
   i = i + 1;
   call symput("f"||left(put(i,7.)), trim(left(scan(fname,1,'.'))));
   call symput("fcnt", trim(left(i)));
run;

%put &amp;amp;f1;


libname insas "&amp;amp;sasdir";
%macro dothis;
%do i = 1 %to &amp;amp;fcnt;
libname tranfile xport "&amp;amp;xptdir\&amp;amp;&amp;amp;f&amp;amp;i...xpt";
  proc copy in=insas out=tranfile memtype=data;
   select &amp;amp;&amp;amp;f&amp;amp;i;
  run;
%end;
%mend dothis;
%dothis;

%mend sas2xpt;


**example toc all the macro**;

%sas2xpt(sasdir=%str(\\itsu.com\\Analysis\Working_Folder\ads), xptdir=(\\itsu.com\\Analysis\Working_Folder\ads) );
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;folder structure:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HitmonTran_1-1731734726770.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/102284iF22EC1CCA91B221D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HitmonTran_1-1731734726770.png" alt="HitmonTran_1-1731734726770.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 05:25:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/error-message-with-converting-sas-data-to-xpt-format/m-p/950988#M371814</guid>
      <dc:creator>HitmonTran</dc:creator>
      <dc:date>2024-11-16T05:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: error message with converting sas data to xpt format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/error-message-with-converting-sas-data-to-xpt-format/m-p/950993#M371816</link>
      <description>&lt;P&gt;The following code is what I wrote for one to one converting to xpt file of V5.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname in v9 'c:\temp\SAS'    access=readonly;   /*the path of sas datasets*/
%let path_out=  c:\temp\XPT   ;                   /*the path of xpt after converting*/

/*one dataset corresponding to one xpt file*/
data _null_;
 set sashelp.vtable(keep=libname memname where=(libname='IN'));
call execute(cat("libname tranfile xport '&amp;amp;path_out\",lowcase(strip(memname)),".xpt';proc copy in=in out=tranfile ; select ",strip(memname),";run;"));
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 06:43:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/error-message-with-converting-sas-data-to-xpt-format/m-p/950993#M371816</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-11-16T06:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: error message with converting sas data to xpt format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/error-message-with-converting-sas-data-to-xpt-format/m-p/950996#M371817</link>
      <description>&lt;P&gt;The issue is:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1731750989816.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/102286iF2660216FEE4C13C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1731750989816.png" alt="Patrick_0-1731750989816.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would have to use something like powershell in your pipe command. The default cmd.exe simply doesn't support UNC paths. This is a Microsoft thing and nothing you can change.&lt;/P&gt;
&lt;P&gt;But... There is really no need to use an external command which requires XCMD to list files and especially SAS tables. Just use an approach along the line of what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;already proposed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to use your current code as-is then you need to map this UNC path (=give it a drive letter) on the machine where SAS executes.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 10:01:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/error-message-with-converting-sas-data-to-xpt-format/m-p/950996#M371817</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-11-16T10:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: error message with converting sas data to xpt format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/error-message-with-converting-sas-data-to-xpt-format/m-p/951001#M371818</link>
      <description>&lt;P&gt;So the issue does not appear to be the conversion to XPORT files. Instead it is the attempt to force WINDOWS to use a UNC path as the current working directory.&amp;nbsp; That is not possible.&amp;nbsp; And not needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are plenty of ways to get the list of files in a directory.&amp;nbsp; You can even use pure SAS code.&amp;nbsp; See&amp;nbsp;&lt;A href="https://github.com/sasutils/macros/blob/master/dirtree.sas" target="_self"&gt;%dirtree()&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you could just make a small change to your current code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   infile "dir /b &amp;amp;sasdir\*.sas7bdat" pipe truncover;
   input fname $200. ;
   call symputx(cats('f',_n_),scan(fname,1,'.'));
   call symputx("fcnt",_n_);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also you are passing () around the value of the target directory in your macro call, which will cause the wrong filenames to be generated.&amp;nbsp; Did you intend to wrap that path in a %STR() macro function call also?&amp;nbsp; Note that the %STR() is not needed for the example paths you are showing since they do not include any macro triggers that need masking.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%sas2xpt
(sasdir=\\itsu.com\Analysis\Working_Folder\ads
,xptdir=\\itsu.com\Analysis\Working_Folder\ads
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 21:34:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/error-message-with-converting-sas-data-to-xpt-format/m-p/951001#M371818</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-11-16T21:34:51Z</dc:date>
    </item>
  </channel>
</rss>

