BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,

In my project the sas files are kept in SAS catalogue. I can view the SAS files from the catalogue from Base SAS but I need to copy these sas files out of SAS cataloge to a location of windows.


Please suggest.
4 REPLIES 4
deleted_user
Not applicable
To Clarify my requirement, in my case all the SAS source files have been kept in a SAS Catalogue. My requirement is to send some of the SAS source files to analytics user from the catalogue. Is there any way to get the sas files out of catalogue so that i can send only the required sas files.
Patrick
Opal | Level 21
If I understand you right then all the SAS source code is stored as compiled macros in a macro catalogue together with the uncompiled source code.

If so then check if %COPY does what you need: http://support.sas.com/onlinedoc/913/getDoc/en/mcrolref.hlp/a002582616.htm

HTH
Patrick
Cynthia_sas
SAS Super FREQ
Hi:
There are many different types of catalogue entries that you could have. The ENTRY type is determined by the "4 level name" -- here are some examples:
[pre]
library.catalog.program.source
library.catalog.program.scl
library.catalog.program.macro
library.catalog.entryname.format
library.catalog.graphname.grseg
library.catalog.entryname.program
library.catalog.entryname.menu
library.catalog.entryname.list
[/pre]

For macro-related entries (if that is what you have), the documentation for the %COPY syntax is here:
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#/documentation/cd...

Otherwise, look at the syntax for the CATALOG procedure:
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#/documentation/cdl/en...
and the COPY example:
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#/documentation/cdl/en...

cynthia
Peter_C
Rhodochrosite | Level 12
Deepu
you say you "can view the SAS files", so I'll assume that these are are catalog entries of type SOURCE. (i would not expect to view the contents of a compiled macro).
The following CODE assigns two "aggregate storage locations". First pointing at your catalog, Second is pointing at a folder in which you want to write the SAS files.[pre]filename sfrom catalog 'libname.catname' ;
filename sto 'your destination path\' ;
* now create a dataset listing all source entries in the catalog ;
proc sql noprint ;
create table work.sources as
select objname from dictionary.catalogs
where libname='LIBNAME' and memname='CATNAME'
and objtype='SOURCE' ;
quit ;
data _null_ ; * now do the copies ;
set work.sources ;
length from_obj to_textf $80 ;
retain sto "%sysfunc(pathname(sto))" ;
to_textf = cats( sto,'\', objname, '.sas' );
from_obj = cats( 'libname.catname.', objname, '.source' ) ;
putLog 'reading from ' from_obj +1 'to write ' to_textf ;
eof_cat_entry = . ;
infile dum device=catalog filevar= from_obj end= eof_cat_entry ;
file dmy filevar= to_textf ;
do lines=0 by 1 while( not eof_cat_entry ) ;
input ;
L= length( _infile_ ) ;
put _infile_ $varying256. L ;
end ;
putlog 'wrote ' lines +1 'lines.' ;
run ; [/PRE]
On testing, I couldn't make the FILEVAR= feature support "aggregate storage location" filerefs. (you may be more sucessful).
a piece of sas history convenience :: in the syntax [pre] %include sfrom(program1) ;[/pre]"sfrom" is an aggregate storage location also known as a logical reference that points to a folder, directory or catalog, or pds (subject to the platform terminology).
It serves the purpose of abbreviating the syntax (logical reference is allowed only an 8-wide SAS name) and being defined once and used many times, the logical reference reduces the number of places referring to physical paths.[pre] sfrom(program1) [/pre]refers to a program file named program1.sas or program1.source, or program1.catams or just "program1" (depending on the platform and certain system options) in that aggregate storage location. Because of this convenience, an aggregate storage locations often called a "program library".
//end of history
fortunately, the base sas language provides the functions and operators which enable the code above to convert from logical reference to physical reference.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 785 views
  • 0 likes
  • 4 in conversation