Dynamic file creation thru SAS

sas

    Sponsored Links

    Next

  • 1. multiples responses and consecutive duplicate
    Hello, I am wondering if following program could be perfected or if there is another method to attack the problem In the sasdata, they are maximum twelve answers (ap1-ap12) (length $ 2) but the real number of answer is indicated in nbapp The goal is to reduce all consecutive same answers to only one answer. Some observations have 7 or 8 same 'strictly following' answers (ex ap2 ap3 ap4 ap5 filled with 'CD' become ap2='CD' and ap3 takes the contents of ap6) %macro nodup; %do i=1 %to 12; do i=2 to nbapp; if v(i-1)=v(i) then v(i)=' '; if v(i)=' ' and (i<nbapp) then do;v(i)=v(i+1);v(i+1)=' '; end; end; %end; %mend; data tempo.nettoye1; set tempo.appreciations; array v(*) ap1-ap12; %nodup run; TIA Andre Andre Wielki INED (Institut National d'Etudes Dographiques) 133 Boulevard Davout 75980 Paris Cedex 20 33 (0) 1 56 06 21 54 FRANCE
  • 2. GOOD DAY
    From:Dr Evangelise Chris 40 Street, East London, South Africa. Dear Sir/Madan, l am a financial consultant based in East London South Africa. l have a client (a widow) she has $30,000,000 USD with a private equity investment trust company in Europe for safekeeping. And she is willing to offer you 20% of the total fund if you can assist her transfer this fund to your country or any bank of your wish.She wishes to invest in a stable economy. Her interest is in companies with potentials for rapid growth in long terms.My client is interested in placing part of her fund in your company,if your country`s bi-laws allows foreign investment. You can contact me for more details via this email Address: XXXX@XXXXX.COM Yours faithfully, Dr Evangelise Chris N:B The fund is free from drug and laundering related offences and this transaction need utmost confidentiality
  • 3. Translate Keyword "by" into SPSS
    Hi! I have to do some calculations in SPSS but I havent found anything like the "by" Statement in SAS. Does anybody know how to translate proc forecast; by var1; into SPSS? Any help is highly appreciated! Thanks in advanced! J
  • 4. DataFlux IntelliServer problem
    Hi all, I'm trying to run the sample jsp application found in the DFIntelliServer User Guide (page 69, enter.html and enter.jsp). When I launch the application (enter.html) everything works fine, but when enter.jsp is called I get this error: ERROR: dfClient failed with error 901 (could not load system libraries) Unable to add new customer Could someone help me to understand this error? I'm new to DFIntelliserver. Thank you, Pierre Blanc Note: my real e-mail address is blanc_teutoburgo AT yahoo.it
  • 5. Combining multiple variables
    Hi, I am a beginner with SAS and I would really appreciate if anyone can help me with this. I have a dataset as follows _NAME_ Code1 Code2 Code3 ...............Code19 Sales 01 03 02 02 Sales 06 04 02 05 I wanted to concatenate all Code1..Code19 variables into a single variable as follows Bar_Code = 010302.....02 The problem i am having is that i want to dynamically concatenate it based on the number of variables (as no. of code variables are not constant). Any pointers in this direction would be really helpful. Thanks in advance. Tony.

Dynamic file creation thru SAS

Postby Kannan » Sat, 21 Apr 2007 05:27:34 GMT

Hi All,
   We have SAS on mainframe.
I have situation where I need to dynamically create the file for each
unique Warehouse number. Below is the code I created to dynamically
allocate the files in mainframe.It is running fine for all the
situations except if there is out of space error. In other words the
file I am allocation has some default space limit if it exceeds that
limit my job getting failed.
My question:
   Is there any way I could increase/control the size of the output
file while creating the file dynamically. I have controlled the file
record length by using LS statement. I appreciate all your help.

Thanks!
Kannan.


Please find the below code:

Data Sas1;
Infile Whsefile;
Input @001 Whse    $char05.;
          @006 Items    $char100.;

Proc Sort;
By Whse;

data _null_;
set sas1 end=x; by Whse;
if _n_ = 1 then do;
   file print notitles;
   put / '               files created in this            ' /
         '              **************************        ' ;
end;

if first.whse then do;
   cnt+1;
   length fname $44.;
   fname=compress('myuid.whse.w'|| Whse||'.csv');
   link file_delete;
end;

file dummy filevar=fname mod recfm=fb Ls=105;
put @001 Whse $char05.;
      @006 Items $char100.

if x then do;
file print notitles;
put /
    'count of files generated : ' cnt;
end;
return;

file_delete:
rc1=0;
fn="tempfile";
rc=filename(fn,fname);
if rc = 0 and fexist(fn) then do;
       rc1=fdelete(fn);
       rc=filename(fn);
end;
if rc1  0 then do;
   put 'file deletion not successful';
   abort abend;
end;
return;


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 74 guest