- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
I have a PDS 'userid.myname.other' with 3000 members I want to read all the members of that pds and write it in to a new PDS. I have few conditions for writing the members.
Conditions: 1. all the members have a particular name say sasexe on a fixed column but the row may varies. I want to start writing the members only when after sasexe all the lines before that has to be omitted.
2. Likewise writing the output file has to be stopped when the when another keyword is encountered which is also common in all the members.
I'm attaching my sample code here. which is not working as expected. Can someone help me out on this?
code:
DATA TST1;
LENGTH FILENAME $40.;
INFILE FILE01;
INPUT @1 PGM $8.;
Inp_NAME = "input.file.name(" ||TRIM(PGM)|| ")";
out_NAME = "output.file.name(" ||TRIM(PGM)|| ")";
RUN;
DATA REC_OT(KEEP=REC);
LENGTH MYINFILE $400.;
SET TST1;
INFILE INDUMMY FILEVAR=Inp_NAME FILENAME=MYINFILE END=DONE;
DO WHILE(NOT DONE);
INPUT @1 REC $CHAR80.
@3 JOB $CHAR8.
@12JOB1 $CHAR4.;
INDIC=0;
INDIR=2;
IF (INDEX (JOB,"sasexe" ) > 0) THEN DO;
FILE OUTDUMMY FILEVAR=Out_NAME OLD;
PUT @1 REC;
IF (INDEX (JOB1,"EXEC") >0) THEN DO;
INDIC = INDIC+1;
END;
IF (INDIC = INDIR) THEN DO;
PUT "//*******";
DONE=1;
END;
END;
END;
FILE MESSAGES NOPRINT;
PUT 'FINISHED READING ' MYINFILE=;
RUN;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What is a PDS?
Please provide test data in the form of a datastep in a code window (its the {i} above the post):
Please also provide what you expect to see from that test data.
Please also avoid coding all in uppercase, its like shouting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Sorry for the Caps. Since we are working on Mainframe SAS I cannot avoid it.
PDS is partitioned dataset which is used in mainframe as a folder. I will rephrase my question.
Lets just consider a single file with 5 paragraphs. I want to write a code to copy only the para that starts with SASEXE and ends with EXEC.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
From all I infer, it's about mainframe partitioned datasets, which also explains the uppercase coding. Although not necessary, many MF coders are still stuck in the 1950's.
I'd get hold a of a good JCL programmer and do it with MF text processing tools.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@Kurt_Bremser Yes, It can be done using JCLs but I have started learning SAS and would like to give a try using this SAS.
We can assume my input like this for Opensource SAS.
Jobstep4...... Hello all nice to learn sas ..... exec.
Jobstep...... Hello all welcome to sas ..... exec.
Jobstep2...... Hello everyone welcome to sas.... exec
Jobstep.6..... Hello all sas is good ..... exec.
lets assume all the lines above are paragraphs and I need the para that starts with Jobstep2 and ends with exec .
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I can see a couple of errors in your code:
- You forgot a left paranthesis in "output.file.name" ||TRIM(PGM)|| ")";
- You put your filenames in INP_NAME and OUT_NAME, but your FILEVAR variables are named IDS_NAME and ODS_NAME
Not sure if that is enough to accomplish what you want, but it may help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@s_lassen Thanks for pointing things Lassen. But it didn't work after correcting those things. I'm almost done on this and will share the code once it is completed.