SAS Programming

DATA Step, Macro, Functions and more
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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