Date: Wed, 4 Jul 2007 01:32:14 +0000
Reply-To: iw1junk@COMCAST.NET
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ian Whitlock <iw1junk@COMCAST.NET>
Subject: Re: Operating system , data _null_ questions ??
Summary: Some answers to questions with simple DATA step to assign
librefs and filerefs on multiple systems.
SAS_Learner,
Long, long ago, there was a "Program Editor" patterned after the ISPF full
screen editor for the IBM mainframe. You can still get there by going to
the menu view and choosing Program Editor. With this system when the code
in the editor is submitted, the code disappears from the editor. F4 is the
key to recall the last submitted code. The key also works for the
"Enhanced Editor" except that the submitted code doesn't disappear. It can
be handy when you keep changing code and submitting it, and then realize
sometime back you had the best version. Erase, hit F4, and repeat until
you reach the appropriate version.
Some programs are generated, for example, the programs that come from PROC
IMPORT. You can use F4 to get the generated code. Some people like the
Program Editor, some like the Enhanced Editor. Each has its virtues and
limitations, so some people choose depending on the situation.
The option NOREPLACE can be important, by default REPLACE can destroy a
permanent data set with as minor a mistake as one missing semicolon.
data w
set lib.base ;
run ;
The message W, SET, and LIB.BASE written with 0 observations.
The code
%let repl=%sysfunc(getoption(replace,keyword));
options replace;
simply gets the current system option for REPLACE and saves it, then it
sets the option to replace, so that an existing data set can be
overwritten. Later the line
options &repl ;
will return the option to its previous setting. The idea is good, when you
write code to be used by someone else in another program, you want to be
polite and return the system they way it was previously set, but for your
immediate needs you need to control the option.
The code you asked about has the comment
/* create sample data and assign librefs and filerefs */
This explains the purpose of the DATA step. It is written in terms of
function calls to primitive functions. If you want to know more about
them,
you can look them up in the help facility of the standard version or use
the online documentation at
http://support.sas.com/onlinedoc/913/docMainpage.jsp
These functions were originally introduced in SCL as a part of SAS/AF for
doing low level operations similar to C. The functions were later
incorporated in the DATA step and are handy in macro when used in
conjunction with %SYSFUNC.
The original code that you showed was written to handle a very special
situation of placing certain datasets in the library SASUSER. So it is not
only complex and sophisticated, but not very general. Now let's look at a
simpler solution to your problem which more suitable to a SAS programmer
who wants to assign LIBREFS and FILEREFS under multiple systems
automatically. I will illustrate with just PC code, since that is the
only system I can test.
data _null_ ;
input sysscp $ rem &:$char100. ; ;
if sysscp = "&sysscp" then
call execute ( trim(rem) || ";" ) ;
cards ;
WIN LIBNAME FIRST "C:\JUNK"
WIN FILENAME code temp
;
Just replace with all LIB's and FILE's you want with the appropriate values
of &SYSSCP for your systems and you are ready to go. The program may not
be as clever as the code you showed, but it is clear and easy to modify for
each program.
The same system could be used to handle a production system (PROD) and test
system (TEST), simply replacing &SYSSCP with &MYSYS where the value is
either PROD or TEST.
Ian Whitlock
================
Date: Sat, 30 Jun 2007 14:15:09 -0500
Reply-To: SAS_learner <proccontents@GMAIL.COM>
Sender: "SAS(r) Discussion"
From: SAS_learner <proccontents@GMAIL.COM>
Subject: Operating system , data _null_ questions ??
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Hello Guys,
Sorry guys for a very Long email Please bare with me as I am too many
questions ??
I have seen this piece of code when on the sas9 -----> Help ------->
Learning SAS programming, When you say yes I think sas runs some code and
only thing you see is "Sample data sets and files are ready." in the Log
Accidentally when I pressed F4 the following code appeared in the Editor.
Well here I have lot of questions like how can you can customize one of
the menu Items to run a program and do not so show the code in both in the
editor or Log ( I think in the Log they did by using %let
repl=%sysfunc(getoption(replace,keyword));options replace; , My next search
to Google what does Options Replace does )
Second thing First Piece of code I think Author is telling SAS to look
for what kind of Operating system it is ran on right ??, Here I am
thinking that if SAS can recognize what is Operating system can we use
similar this piece of code and define Libnames ( The reason why I am
asking is this at the Place I work for the DM work we submit Jobs on
OpenVms and for stat work we use Batch (windows ) submit and we change
the libnames structure for submitting the Jobs ) What is difference of
using on different Operating System ??
And in the second and third piece of code they used to data _null_ both
to create a dataset and program and put out to folder ? what is possible
advantage of this method ? I could see that they have used those programs
and datasets in the array statements but I did not understand the authors
purpose why he did that way . This seems to great way of writing programs
and calling them when needed, can you explain more of how to do and what
are things I need to keep in mind ??
Can you explain of what does this following code does ??
<SNIP>