BookmarkSubscribeRSS Feed
Mano3116
Calcite | Level 5

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;

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26

What is a PDS?

Please provide test data in the form of a datastep in a code window (its the {i} above the post):

https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

 

Please also provide what you expect to see from that test data.  

Please also avoid coding all in uppercase, its like shouting.

Mano3116
Calcite | Level 5

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.

 

 

Kurt_Bremser
Super User

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.

Mano3116
Calcite | Level 5

@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 .

 

s_lassen
Meteorite | Level 14

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.

Mano3116
Calcite | Level 5

@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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1230 views
  • 0 likes
  • 4 in conversation