f



Re: running a sas file within a sas file

Like Joep wrote: that seems to be the right thing for the macro facility.
With %include you are very static. With the macro facility that could be
very dynamic. The simplest thing is: you could provide the statements you
want to insert as parameter:

%macro doit(stmt1=,stmt2=);
.....
&stmt1
.....
&stmt2
.....
%mend;
%doit(stmt1=%str(y=sqrt(y);),
      stmt2=%str(if y<2 then y=2;)
     );

with many other things you can do, e.g. conditional creating of
statements, naming variables by parameters, create multiple statements
with macro loops and much more.

On the other hand: if you want to do such simple things like you wrote,
avoid any %INC or %MACRO things!
It is far more readable, if you don't use %INCLUDES. What do you think,
that data-step will do:

data a;
 %inc(inc1);
 %inc(inc2);
 %inc(inc3);
run;

???

instead of:
data a;
  set sashelp.class;
  if age>11 then age=11;
  keep name age;
run;


Gerhard








On Mon, 9 Jun 2008 01:42:03 -0700, Joep Steeman
<jsteeman@BUSINESSDECISION.COM> wrote:

>On 9 jun, 09:20, zpe...@NATURE.BERKELEY.EDU (Zach Peery) wrote:
>> Sorry to bug you all with such an easy one, but I havent had much luck
>> with the usual help sources.
>>
>> I just want to run a sas program file within a sas program file.  For
>> example, in sas file 1 I want to set x equal to 2, then with file 2
>> invoked by file 1, I want to set y = 3.
>>
>> So sas file 1 looks like this...
>>
>> data data;
>> x = 2;
>> ***How do I invoke sas file 2 which sets y = 3 here???***
>> run;
>>
>> Thanks!!!
>
>Here is a way.
>
>sas file 2 saved as your_file_location\inclfile2.sas:
>y = 3;
>
>sas file 1:
>data test;
>  x = 2;
>  %include 'your_file_location\inclfile2.sas';
>  put (_all_ ) (=);
>run;
>
>One could think macro, which could operate in much the same way, but
>can be more flexible.
>
>%macro setvar(v=y);
>  &v = 3;
>%mend setvar;
>
>sas file 1:
>data test;
>  x = 2;
>  %setvar(v=z);
>  put (_all_ ) (=);
>run;
>
>There are other ways as well. My question would be: why would you want
>this and in this way?
>
>Regards, Joep
0
6/9/2008 9:49:23 AM
comp.soft-sys.sas 142828 articles. 3 followers. Post Follow

0 Replies
965 Views

Similar Articles

[PageSpeed] 26

Reply:

Similar Artilces:

running a sas file within a sas file
Sorry to bug you all with such an easy one, but I havent had much luck with the usual help sources. I just want to run a sas program file within a sas program file. For example, in sas file 1 I want to set x equal to 2, then with file 2 invoked by file 1, I want to set y = 3. So sas file 1 looks like this... data data; x = 2; ***How do I invoke sas file 2 which sets y = 3 here???*** run; Thanks!!! On 9 jun, 09:20, zpe...@NATURE.BERKELEY.EDU (Zach Peery) wrote: > Sorry to bug you all with such an easy one, but I havent had much luck > with the usual help sources. > > I just want to run a sas program file within a sas program file. For > example, in sas file 1 I want to set x equal to 2, then with file 2 > invoked by file 1, I want to set y = 3. > > So sas file 1 looks like this... > > data data; > x = 2; > ***How do I invoke sas file 2 which sets y = 3 here???*** > run; > > Thanks!!! Here is a way. sas file 2 saved as your_file_location\inclfile2.sas: y = 3; sas file 1: data test; x = 2; %include 'your_file_location\inclfile2.sas'; put (_all_ ) (=); run; One could think macro, which could operate in much the same way, but can be more flexible. %macro setvar(v=y); &v = 3; %mend setvar; sas file 1: data test; x = 2; %setvar(v=z); put (_all_ ) (=); run; There are other ways as well. My question would be: why would you want this and in this way? Regards, Joep ...

Re: Is there a system option for OpenVMS SAS version 8 where a sas program can create an output file with a file attribute of "Stream_LF" so that these external files c
Charles Patridge <charles_s_patridge@PRODIGY.NET> wrote: > Is there a system option for OpenVMS SAS version 8 where a sas program can > create an output file with a file attribute of "Stream_LF" so that these > external files can be served through an Apache WebServer properly? > > Currently, what happens is when we create a CSV file, the Apache Webserver > wants to load the contents of this CSV file into a single cell for Excel. > That is, all OBS are treated as a SINGLE record and all the contents is > loaded into a single cell within Excel. > > T...

Executing separate SAS File from Main SAS File
Hi All I was wondering if I can initiate execution of SAS code stored in a SAS file from my main SAS code. Help very much appreciated. Thanks Toby See %include -----Original Message----- From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu]On Behalf Of tobyrathgeb@stanford.edu Sent: Tuesday, August 02, 2005 2:42 PM To: sas-l@uga.edu Subject: Executing separate SAS File from Main SAS File Hi All I was wondering if I can initiate execution of SAS code stored in a SAS file from my main SAS code. Help very much appreciated. Thanks Toby __________________________________...

Re: View files with SAS extension in SAS explorer
The SAS explorer shows you sas datasets (.sas7bdat), not programs (.sas). Open program... wil let you open SAS programs (From the file menu). -Joe On Tue, Mar 9, 2010 at 4:37 PM, franwdwyer@googlemail.com < franwdwyer@googlemail.com> wrote: > Hi everyone, > > I'm just new to SAS and this list and have this question. > > If I create a new library in SAS Explorer and then I save some SAS > programs to it (.sas extension), how come I can't see these types of > file in the SAS Explorer? > > Thanks for any help, > > Fran > ...

Re: Running SAS programs from within a SAS program
Keith, You can use a series of %include statements naming the programs in the order you want to call them in. %include "drive:\your_folder\program name.txt" ; Mah-J M. Soobader, PhD Principal consultant STATWORKS www.statworks.com -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of Keith W. Larson Sent: Friday, November 18, 2005 10:32 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Running SAS programs from within a SAS program Dear All, I have several small(ish) SAS programs that convert and format DBF files. Thanks to all who helped solve...

Re: converting sas transport files into sas datasets
Once you have assigned an xport libname you can read it in like a normal dataset. libname out xport 'C:\Documents and Settings\kdt\Desktop\class.xpt'; *- Create xport file; data out.class; set sashelp.class; run; *- Create work file from xport file; data work.class; set out.class; run; 2008/12/17 <pramila.sami@gmail.com>: > Hello All, > > Could anyone please give me the code for converting sas transport > files into sas datasets. thanks in advance. > ...

Re: Running a SAS program within a SAS program #3
Kathleen, You can use %INCLUDE in a SAS program to call other SAS programs. Jack Clark Research Analyst Center for Health Program Development and Management University of Maryland, Baltimore County -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Kathleen Santos Sent: Monday, April 21, 2008 12:55 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Running a SAS program within a SAS program Hello, I would like to combine multi years of data into one. Each year has a particular data set and a particular program to create a SAS dataset. However, not all programs are the same (e.g. variable names may change throughout the years). What I would like to do is to create one program that would call on the other programs to create SAS datasets. Then I'll integrate them together and do whatever I it is I need to do. I hope someone can help me. Thanks. Kathleen ...

Is there a system option for OpenVMS SAS version 8 where a sas program can create an output file with a file attribute of "Stream_LF" so that these external files can b
To SAS-Lers (specifically OpenVMS Users), Is there a system option for OpenVMS SAS version 8 where a sas program can create an output file with a file attribute of "Stream_LF" so that these external files can be served through an Apache WebServer properly? Currently, what happens is when we create a CSV file, the Apache Webserver wants to load the contents of this CSV file into a single cell for Excel. That is, all OBS are treated as a SINGLE record and all the contents is loaded into a single cell within Excel. To fix this problem, we are able to use an "Convert/FDL" th...

Re: Unix SAS: How to save log file while in SAS session? #2
On Wed, 18 Aug 2004 12:18:03 -0500, Duck-Hye Yang <dyang@CHAPINHALL.ORG> wrote: >Hello, > >I am using SAS Unix Display manager. >I put together single small sas programming files in one giant sas programming file. >I need to save log and output files AFTER each single small programming file. >The problem is that I do not know how to save log and output while in SAS session. > >Below is the outline of what I'd like to do: > > >DM 'clear log'; >DM 'clear output'; >SAS 1 programming start here >end here >x 'file "SAS...

Re: Possible to run a SAS program within another SAS program? #3
why just last week, we discussed this: Date: Mon, 21 Nov 2005 11:01:30 -0500 Subject: Re: Running SAS programs from within a SAS program http://www.listserv.uga.edu/cgi-bin/wa?A2=ind0511C&L=sas-l&P=R33664 Ron Fehd the %include maven CDC Atlanta GA USA RJF2 at cdc dot gov > -----Original Message----- > From: osei the dude > Hello, I have 9 SAS programs, all within the same Windows > folder that I > usually run at the same time - one right after the other. For > convenience, is it possible to write a simple SAS program > that will let > me run ...

Re: Exporting a SAS data set to Text file on SAS unix #3
hi ... actually, what I posted earlier was too much code (sorry) this is enough (a bit more succinct) * variable names into a macro variable (tab separated); proc sql noprint; select name into :vars separated by '09'x from dictionary.columns where libname eq 'SASHELP' and memname eq 'CLASS' order varnum; quit; data _null_; file 'z:\class.txt' dsd dlm='09'x ; if _n_ eq 1 then put "&vars"; set sashelp.class; put (_all_) (:); run; -- Mike Zdeb U@Albany School of Public Health One University Place Rensselaer, New York 12144-3456 P/518-402...

Re: Possible to run a SAS program within another SAS program? #6
On Wed, 7 Dec 2005 22:32:49 -0800, oseithedude@GMAIL.COM wrote: >nevin.krishna@gmail.com wrote: >> You could use the %include statement to call a specified program. >> for example : >> >> %include "c:\documents and settings\nkrishna\my >> documents\macros\upcase_mac.sas"; >> >> where upcase_mac.sas is a program stored in the above path..so you >> could write an include statement for each program and then copy and >> paste them into any order you need..unless of course i am >> misunderstanding your needs..:-) >> >...

Re: How to convert SAS file to .v5x file?
Miranda - What application is a .v5x file? Are saying a SAS v5.18 file? Paul Choate DDS Data Extraction (916) 654-2160 -----Original Message----- From: miranda [mailto:mixiao@UCLA.EDU] Sent: Friday, January 23, 2004 3:05 PM To: SAS-L@LISTSERV.UGA.EDU Subject: How to convert SAS file to .v5x file? Hi , Does anyone know how to alter SAS 8.2 data files to .v5x files? Thanks. ...

Re: PC SAS 9.1
> From: Jon Hayward > Is there a setting in PC SAS so that whichever directory I > save my .sas file to, SAS will automatically go there when I > want to save my .log and .lst files? > > Currently I must specify each location. While I am sure that > there is a reason for this, I am hoping that there might be a > setting to allow me to specify that I want SAS to remember my > current active location for the duration of that session... > So the next time I open SAS, I will perhaps save a different > .sas file to a different location and then SAS will know to >...

Re: PC SAS 9.1
Hi Jon, If you run SAS in batch mode the dir the .sas file is in will by default be the dir where the .log and .lst files will be left. Regards - Jim. -- Jim Groeneveld, Netherlands Statistician, SAS consultant home.hccnet.nl/jim.groeneveld My computer remains home while I will attend PhUSE 2006 in Dublin. On Tue, 12 Sep 2006 09:23:15 -0400, Jon Hayward <jhayward1@BABSON.EDU> wrote: >Hi - > >Is there a setting in PC SAS so that whichever directory I save my .sas >file to, SAS will automatically go there when I want to save my .log >and .lst files? > >Currently...

Re: Exporting Sas file to a csv extension file
Randy, Remove the semicolon from the first line, plus you may need to add a dbms option. For example, try something like: proc export data = Datahave outfile = 'C:\dataneed.csv' DBMS=csv REPLACE; run; HTH, Art -------- On Sun, 28 Sep 2008 14:00:24 -0400, Randy <randistan69@HOTMAIL.COM> wrote: >I have to convert a sas data file to a csv format file >My code is > >proc export data = Datahave; >outfile = 'C:\dataneed.csv' ; >run; > >The log gives me an error message >ERROR: FILE= or TABLE= is required and must be specified. > >What is the mistake that I am making? ...

Re: How to change .xls files into .txt files in SAS
Hi Gadde, Can you just open them in Excel, do a SaveAs, change the filetype to .txt and click OK? or do you have so many files that you want to automate this process? Are you wanting SAS to find all the ..xls files in a directory and then convert and output them? SAS can do that. and if you have so many files, we have to ask if these are of "like" things, and would it not be better to have them consolidated, but of course we have no idea what you circumstances are. Hope this is helpful. Mark Terjeson Senior Programmer Analyst, IM&R Russell Investment Group Russell Gl...

Re: How to convert SAS file to .v5x file? #2
As of version 7 SAS libraries were not backwards compatible (for writing) with version 5. If you have a third party application that needs a SASv5.18 file then you'll need to export from SAS to a different compatible filetype from that era such as CSV, WK1, or dbase that your application can import. Paul Choate DDS Data Extraction (916) 654-2160 -----Original Message----- From: Choate, Paul@DDS [mailto:pchoate@DDS.CA.GOV] Sent: Friday, January 23, 2004 3:36 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: How to convert SAS file to .v5x file? Miranda - What application is a .v5x file? Are ...

converting sas transport files into sas datasets
Hello All, Could anyone please give me the code for converting sas transport files into sas datasets. thanks in advance. ...

Running SAS programs from within a SAS program
Dear All, I have several small(ish) SAS programs that convert and format DBF files. Thanks to all who helped solve formatting problems. I would like to create a master SAS program that calls each one in sequence. Any ideas? Cheers, Keith __________________________________ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com Keith, You can use a series of %include statements naming the programs in the order you want to call them in. %include "drive:\your_folder\program name.txt" ; Mah-J M. Soobader, PhD Principal consultant STATWORKS www.s...

Opening non SAS files with BASE SAS ?
Is there a function that executes a non SAS file? I've written a macro that outputs a file with the extention SQL (EXE would also be helpful). *.SQL files are associated with SQL server on my computer so I'd like to make SAS execute this file so it triggers the SQL server program. Is this possible? Thank You, Aaron ...

Re: Autoexec.sas file Dm"pgm;zoom;"; doesnot wrk in SAS 9.2 #2
Hi Ace, The PGM is the editor window up through v6.12 but also still exists today. For the Enhanced Editor you can use: dm editor 'zoom' wedit ; Hope this is helpful. Mark Terjeson Investment Business Intelligence Investment Management & Research Russell Investments 253-439-2367 Russell Global Leaders in Multi-Manager Investing -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Ace Sent: Wednesday, October 14, 2009 5:49 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Autoexec.sas file Dm"pgm;zoom;"; doesnot wrk in SAS...

Re: Making external file with the same length as the original SAS file
Is there a LRECL specified on your file statement? You may be exceeding the default of 256. The default RECFM is variable, so it does not matter if you specify too large of a record. LRECL=record-length specifies the record length (in bytes). Under Windows, the default is 256. The value of record-length can range from 1 to 1,048,576 (1 megabyte). Another problem may be CR/LF's in your data. Are the records breaking on a certain field? Windows FILE Statement http://v8doc.sas.com/bin/ixcgisol/sashtml/win/zmd-file.htm (User:SAS Pwd:onlinedoc) hth Paul Choate DDS Data Extraction (916) ...

Re: Exporting Sas file to a csv extension file #2
I have been cleaning up a pile of email and I don't recall seeing a reply to this question. Remove the semicolon after Data=Datahave proc export data = Datahave; <<<<===================== get rid of the semicolon outfile = 'C:\dataneed.csv' ; run; Outfile is part of the proc statement and not a seperate statement. Nat Wooding Environmental Specialist III Dominion, Environmental Biology 4111 Castlewood Rd Richmond, VA 23234 Phone:804-271-5313, Fax: 804-271-2977 Randy <randistan69@HOTM AIL.COM> To Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU Discussion" cc <SAS-L@LISTSERV.U GA.EDU> Subject Exporting Sas file to a csv extension file 09/28/2008 02:00 PM Please respond to Randy <randistan69@HOTM AIL.COM> I have to convert a sas data file to a csv format file My code is proc export data = Datahave; outfile = 'C:\dataneed.csv' ; run; The log gives me an error message ERROR: FILE= or TABLE= is required and must be specified. What is the mistake that I am making? CONFIDENTIALITY NOTICE: This electronic m...

Web resources about - Re: running a sas file within a sas file - comp.soft-sys.sas

Running - Wikipedia, the free encyclopedia
This article is about the type of locomotion in humans. For running in horses, see Horse gait . For locomotion in dogs, see Gait (dog) . For ...

Clive Palmer on ABC Insiders: Fairfax member won’t rule out running for Senate
CLIVE Palmer has left the door open for a possible tilt at a Senate seat in order to stay in federal parliament.

Canterbury Bulldogs prop David Klemmer in danger of running himself out of NRL
If the firebrand doesn't get in the referee's face, we aren't talking about him touching him

As iOS 9 adoption reaches 79%, most Android users are still running a painfully old OS
Earlier today, Apple updated its App Store dashboard and revealed that iOS 9 adoption has now jumped up to 79%, a slight increase from when Apple ...

Does Anyone Still Feign Surprise When A Blue Dog Finally Comes Out As A Republican? Joe Baca's Running ...
... an adjoining district, CA-31, but was defeated in the primary. A sleazy coked up , New Dem, Pete Aguilar, won that race and Baca is running ...

FLOTUS At SXSW: Talks ‘Let Girls Learn’ & Running For President
In Austin today, First Lady Michelle Obama used her platform at the South by Southwest Music Festival to help 62-million adolescent girls around ...

Security tackles man running toward Trump at Ohio rally
Chicago Tribune Security tackles man running toward Trump at Ohio rally Chicago Tribune A man attempts to rush the stage at a Donald Trump ...

Goose Gossage loses his (bleeping) mind over 'nerds' running baseball
Hall of fame pitcher goes on a profanity-laden tirade about the state of America's pastime, throwing F-bombs like they were strikes.


Chris Matthews Suggests Hillary Clinton Pick John Kasich For A Running Mate
... anti-labor, trickle-down, gives tax cuts to the rich on the backs of the working class, former Lehman Brothers executive as a running mate in ...

Resources last updated: 3/17/2016 1:40:37 AM