LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (April 2010, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 26 Apr 2010 10:23:27 +0200
Reply-To:   Fernández Rodríguez, Dani <DFernandez@CST.CAT>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Fernández Rodríguez, Dani <DFernandez@CST.CAT>
Subject:   Re: X statement
Comments:   To: Jim Groeneveld <jim.1stat@YAHOO.COM>
In-Reply-To:   A<201004252002.o3PAmU6Y018268@malibu.cc.uga.edu>
Content-Type:   text/plain; charset="iso-8859-1"

I am really very interested on this issue. I am actually learning about executing SAS programs in batch mode and using DOS prompt from X statement.

I find Jim ´s answer very usefull (thanks!).

Here my 2 cents:

You can retrieve the path name from a SAS library in a macrovariable. But SAS macros need to be pass to X statement through SAS auto macros.

This is some little things I bring here as a example (the way I copy a Dataset from a library to other one -without using PROC COPY-) :

* first I create a dummy dataset; data _Z5; * WORK lib; do z=1 to 5; output; end; run;

options noxwait; %let path_WORK=%sysfunc(getoption(work)); * WORK lib; X 'mkdir c:\test_1000'; X %unquote(%str(%'copy "&path_WORK.\_Z5.sas7bdat" "c:\test_1000\copy_Z5.sas7bdat" /y%'));

Daniel Fernandez. Barcelona, Spain.

-----Mensaje original----- De: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] En nombre de Jim Groeneveld Enviado el: domingo, 25 de abril de 2010 22:02 Para: SAS-L@LISTSERV.UGA.EDU Asunto: Re: X statement

Hi JKR,

I assume you can access the 64 bits machine in the network using DOS commands, like COPY. Just a few hints/remarks: 1. The X command in macro terms is the %SYSEXEC statement and from a data step it is CALL SYSTEM. 2. You already seem to have a list of files with their paths to be transferred. You could build such a list by applying a LIBNAME statement with an unnamed PIPE to a DOS DIR command that you would parse in a data step, record by record. 3. Using the list you should build a DOS batch (.BAT) file containing the COPY commands for each path\file. Such a batch file is just a text file that you should write using the FILE statement [FILE 'CopyCmnds.BAT';]. 4. The DOS batch file can be run using one of X, %SYSEXEC or CALL SYSTEM. 5. I think you may reassign FILENAMEs and LIBNAMEs at any time but you can also clear them before reassigning: FILENAME fileref CLEAR | _ALL_ CLEAR; id for LIBNAME 6. You may write another macro that for every transport file in the list performs the CIMPORT. That macro should be called from a data step reading the list file using CALL EXECUTE to call the second macro from (possibly surrounded by %NRSTR(%Second(fn)) ), where fn is the value of the line in the list representing the fn, e.g. CALL EXECUTE ('%NRSTR(%Second('||TRIM(FileName)||'));'); 7. Isn't PROC DATASETS capable of doing what I understand you want?

Regards - Jim. -- Jim Groeneveld, Netherlands Statistician, SAS consultant http://jim.groeneveld.eu.tf

On Fri, 23 Apr 2010 15:21:43 -0400, Subscribe Sas-L Jkr <jayakumarreddy@GMAIL.COM> wrote:

>What i have been trying to do is CPORT/Cimport SAS datsets and catalogs from >SAS 9.1.3(32) to sas 9.2(64). Both SAS are installed on diffrent machines. I >want to write an X command in DOS to instruct SAS 9.1.3 in source machine to >pull a path from a text file(which would be list of paths where sas datasets >and catalog reside) and create a transport file and to import the transport >file into 9.2 in the target machine and store under the same path in the >target machine. The file_list.txt is going to have list of complete path at >a folder level where SAS datasets and catalogs reside. > >options noxwait; >%macro cport_cat; >%include "file_list.txt"; >%include "file_count.txt";*****file_count.txt wud have a macro variable >total_file with the count of files******; >%do j=1 %to &totalfile; >x "to extract one path at a time form file_list.txt and pass it to source.txt" >%include "source.txt"; >end; >%do i=1 %to &total_file; >filename file1 "temp_file&i.";; >libname lib1 v9 "&source";****** i want to pass the path as the argument to >macro variable &source which comes from source.txt***********; >proc cport library=lib1 file=file1; >run; >%mend cport_cat; >%cport_cat; > >thanks >JKR


Back to: Top of message | Previous page | Main SAS-L page