Dynamic file creation thru SAS

sas

    Sponsored Links

    Next

  • 1. Formating table from proc freq
    ODS PATH WORK.Templat(UPDATE) SASHELP.Tmplmst(READ); PROC TEMPLATE; EDIT Base.Freq.OneWayFreqs; EDIT Frequency; FORMAT = COMMA9.; END; EDIT CumFrequency; FORMAT = COMMA9.2; END; EDIT Percent; FORMAT = 9.2; END; EDIT CumPercent; FORMAT = 9.2; END; END; RUN; proc freq; table p9 / missing; weight count; run;
  • 2. Duration of Surgery date
    hello guys, In a Listing I am working I have two dates Sur_Start_date and Sur_end_date in datatime20. format and I am Planning to calculate the Duration of the Surgery, The Problem what would be Ideal way to show time (in Hours or days ) and how do I can address dates across the midnight. Here is what happened in the database if the surgery started on 2008-01-02T23:50 and went over an Hour then date should be technically 2008-01-03T00:50 but in the database it was entered as 2008-01-02T00:50. Thanks for all for your help/Ideas.
  • 3. new forums at Sas discussion Forums
    Andre, Thanks for posting up with the info on the new forums at SI. "Do you think some subject would continue remaining for Sas-L ? " Your question made me chuckle, and I went and visited the SI forums for another look-see. Of course, the SI support forums can't possibly replace the magic that is SAS-L, but we all know that's not their game (right?). IMHO It's good to see SAS making their own alternate universe where the 'little birdies' can visit any discussion subject and provide their insights. As they say, it's no replacement for technical support, but seems to be a logical intermediate step in providing bonified SAS Institute help when those good folks have time to dispense it. However, I think it's a mistake for any forum to chop things up into sub-forums. Some divisions make sense (EG deserves it's own SI forum), but it seems most other topics will naturally cross-over into more than one SAS product or technology. Me? I like SAS-L for the volume of questions and answers, and yes, I thrive on the chaos that is our beloved SAS-L. - Bill McKirgan
  • 4. Wilcoxon signed rank test
    Hi, The null hypothesis tested in wilcoxon signed rank test is that mean or median is equal to zero. My question is: how can I define de null hypothesis? In proc univariate the null hypothesis default of wilcoxon rank test is the mean equal to zero or it is the median equal to zero? Thank you Best Regards Filipa.

Re: Dynamic file creation thru SAS

Postby sbarry » Sat, 21 Apr 2007 06:01:40 GMT



Have a look at the SAS z/OS Companion Guide and the OPTIONS settings
for external file allocations, such as FILESPPRI= and FILESPSEC=, and
others.

 http://www.**--****.com/ 


Scott Barry
SBBWorks, Inc.


Re: Dynamic file creation thru SAS

Postby Kannan » Sat, 21 Apr 2007 23:04:53 GMT

n Apr 19, 5:01 pm, XXXX@XXXXX.COM wrote:

THANK YOU VERY MUCH Scott Barry. Now I am able to control the file
size by giving FILESPPRI= and FILESPSEC=. I have gave 100 for both by
overriding the default value of 1. Thanks again. It was a great help.

I need one more suggestion from you guys.
Right now, I am trying to delete the file if it exist by using the
statement fdelete(fn) where fn is the file reference. If the file is
being browsed by some other user then fdelete would return non-zero
value and hence I am abending the code.
Is there anyway I can stop the sas code for being run until the file
get released. This is something like giving DISP=SHR in JCL.
In more detail
I want to stop the execution of the sas process of a while until the
file get realsed. By this way I can re-allocate the file after the
file is released.

Reason is I am supposed to re-create the file with the same name. In
the meantime the same file might be used by some other process too.

Please send your suggestions.


Thanks!
Kannan.


Re: Dynamic file creation thru SAS

Postby sbarry » Sat, 21 Apr 2007 23:56:57 GMT

n Apr 20, 10:04 am, Kannan < XXXX@XXXXX.COM > wrote:

FDELETE does not provide a similar WAIT= which is used in the FILENAME
allocation technique (similar and would be my recommendation).
Unfortunately, you coding technique which uses the DATA step and
called function FDELETE, would need to be changed. The FILENAME
statement is not executed within a DATA step, but the allocation would
need to occur prior to the start of your DATA step, possibly through
your own "generated" SAS code (consider using CALL EXECUTE or use SAS
macro language), based on your SAS file content, as I understand your
logic. Here's an example of FILENAME as I use it frequently:

options errorabend;
%macro x(myfile);
%if %sysfunc(fileexist)) %then %do;
%* delete file if it exists - get OLD so we can delete it.;
filename del "&myfile" disp=(old,delete,keep) wait=60;
%* now clear the allocation which deletes the file. ;
filename del clear;
%end;
%* allocate the new file. ;
filename out "&myfile" disp=(new,catlg,delete).....;
%mend x;
%x(my.big.wooly.data);


Scott Barry
SBBWorks, Inc.


Re: Dynamic file creation thru SAS

Postby sbarry » Sun, 22 Apr 2007 00:23:13 GMT

n Apr 20, 10:56 am, XXXX@XXXXX.COM wrote:


Sorry, coding mistake - here it is again:

options errorabend;
%macro x(myfile);
%if %sysfunc(fileexist(&myfile)) %then %do;
%* delete file if it exists - get OLD so we can delete it.;
filename del "&myfile" disp=(old,delete,keep) wait=60;
%* now clear the allocation which deletes the file. ;
filename del clear;
%end;
%* allocate the new file. ;
filename out "&myfile" disp=(new,catlg,delete).....;
%mend x;
%x(my.big.wooly.data);


Re: Dynamic file creation thru SAS

Postby Kannan » Sun, 22 Apr 2007 01:11:17 GMT

n Apr 20, 11:23 am, XXXX@XXXXX.COM wrote:

THANK YOU THANK YOU THANK YOU!!!. It is working cool. I am able to
create the files without any problem. If file is used by some other
user , the wait option takinf care of it.
I have copied my sample code here. Please let me know if anything
needs to be changed or tweaked.
Thanks again Scott Barry.



Thanks!
Kannan.
OPTION MACROGEN NOCENTRE MISSING=0;

/*** Reading the input file ***/;
Data PRODFC;
Infile Whsefile;
Input @001 Whse $char05.;
@006 Items $char100.;


/**** Finding unique occurrences ***/;

PROC SORT DATA=PRODFC OUT=UNIFC NODUPKEYS;
BY Whse;


/*** Allocating the files ***/;

%MACRO ALLOCATE(FNAME);

%IF %SYSFUNC(FILEEXIST(&FNAME)) %THEN %DO;
%* DELETE FILE IF IT EXISTS - GET OLD SO WE CAN DELETE IT.;
FILENAME DEL "&FNAME" DISP=(OLD,DELETE,KEEP) WAIT=1;
FILENAME DEL CLEAR;
%END;

%* ALLOCATE THE NEW FILE. ;
FILENAME OUT "&FNAME" DISP=(NEW,CATLG,DELETE) RECFM=FB LRECL=105
SPACE=(CYL,(10,10),RLSE) UNIT=SYSDA;

%MEND ALLOCATE;

DATA _NULL_;
SET UNIFC END=X;

FNAME=COMPRESS('UID.WHSE.W'||Whse||'.TXT');
CALL EXECUTE('%ALLOCATE('||FNAME||')');

I+1;

CALL SYMPUT(COMPRESS('FNAME'||I),FNAME);
CALL SYMPUT(COMPRESS('Whse'||I),Whse);

IF X THEN
CALL SYMPUT('NOOFFILE',I);

RUN;


/*** Writing the file ***/;
%MACRO READ;
%DO I = 1 %TO &NOOFFILE;
DATA _NULL_;
SET PRODFC;
IF Whse="&&Whse&I";
FILE "&&FNAME&I";
PUT @001 Whse $CHAR05.
@006 Items $CHAR100.
;
%END;
%MEND READ;

%READ;


Similar Threads:

1.Rgdng Reading Data from External file & thru cards....

Hi all;

  Can anyone of you please make me understand the concepts of column
pointer,why it is giving two different outputs when the same data is read
from cards and thru an external file....

  My program is like this...

  Data test;
  Input name $ 1-4 age 7-8 id 10-11;
  cards;
  Ruth 45 54
  mahi 68 68
  Sue 45 36
  John 14 25
  ;

 when i run the above program:
 O/P  for 3rd obs SUE is like 3 .

 the same data when stored in external file:with this program
the data is stored in same way in external file as issued through cards,but
still the output varies why..please make me understand...
 data test1;
  infile 'C:\Documents and Settings\admin\Desktop\Applicatation\asd.txt';
  Input name $ 1-4 age 7-8 id 10-11;
  run;

  O/P is :

 Ruth 5 .
 sue 3 .

2.Automated import of dynamic labeled files into SAS

Hi,

I want to write a SAS-Base program which is able to import dynamic
labeled files into SAS. The filenames have no specific pattern. Only
one part of the filename is static. For example:
File 1: attach_first.txt
File 2: attach_hour.txt
...
File 1000: attach_town.txt

The structure of the file content is in every file the same.

Exist in SAS wildcards to read in these Files?

I would be happy to get a solution!

A lot of Greetings from Germany.

Tom

A normal SAS-program with proc import looks like:
proc import datafile="D:\Service\Research\attach_first.txt"
            out=work.attach_first
	    dbms=dlm
            replace;
            delimiter='|';
	    getnames=yes;
run;

3.Dynamic allocation of output files in a SAS program

Hi,
Is it possible to dynamically allocate output files in a SAS program.
I guess it is possible in Assembler.

4.How to get the location of SAS code in the same SAS code thru

Hard to say what you mean with that!
I start a interactive SAS session in Windows, then I include a SAS-program
from "p:\myfiles\test.sas". In that program you want to know, that I
included it from 'p:\myfiles\'? That is impossible! What are YOU doing?
Perhaps you have a batch program on a mainframe which %INCLUDEs a source
from a known location and does... The situation is somehow different then.

You see, without knowing what you are doing, where you are and what you
WANT to do, there is no chance to get it.

Gerhard




On Wed, 11 Apr 2007 07:43:50 -0700, Alok < XXXX@XXXXX.COM > wrote:

>Hi all,
>
>I am facing a problem in which I need to get the location/path of a
>SAS code in a macro variable. I need to use the macro variable in the
>same SAS code. Is there any SAS option available which can do this for
>me? Or is there a code snippet which can achieve the same purpose?
>
>Can you please help me out as soon as possible since I need to deliver
>this tomorrow. Any help will be greatly appreciated.
>
>
>Thanks,
>Alok

5.file creation date

It's so rare I can offer help rather than seek advice from others -

Nina, you can do a proc contents on a file and keep the output.  One field
that will stored is called CRDATE.  That should give you what you need.

e.g.,

proc contents noprint data=myfile out=temp;

data temp; set temp; if _n_ eq 1;

proc print; var crdate;

HTH-

Deb

6. Reading in a flat file with dynamic headers

7. Dynamic sequential file allocation on MVS

8. Sending e-mail thru SAS



Return to sas

 

Who is online

Users browsing this forum: No registered users and 36 guest