DATA Step, Macro, Functions and more

Macro to read and edit PDS members

Reply
N/A
Posts: 0

Macro to read and edit PDS members

Hi All,

I need to find and replace a text string present in the PDS members. From the SAS Forum, http://support.sas.com/forums/thread.jspa?messageID=9643▫

I have managed to write a macro to read the PDS members. Now how should i edit these members, to do find and replace functionality.

Kindly suggest me.

Thanks In Advance.. Message was edited by: Pri
Super Contributor
Super Contributor
Posts: 3,174

Re: Macro to read and edit PDS members

Posted in reply to deleted_user
You can use a DATA step approach to read/write a PDS member (preferably to a new PDS library, not in-place), either using INFILE/FILE or by using a FILENAME allocation. First you will need to read the PDS directory to get the list of members to process - this can be done with PROC SOURCE.

Have a look at the SAS Companion Guide for z/OS.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search arguments, this topic/post:

filename pds site:sas.com
+"proc source" site:sas.com
Valued Guide
Posts: 2,177

Re: Macro to read and edit PDS members

agree with Scott .... you should write a program to create a copy of the whole PDS with any changes you need within any relevant members. Programs add up to a whole lot less diskspace than the data and problems that can be caused by program-update-in-place.
However, PROC SOURCE was built in the days when SAS only ran on IBM mainframes and it was useful to have a "deck" to recreate the "SOURCE" pds with the IBM utility iebupdte. The "Example 4: Update a Library Member" can be found at http://publib.boulder.ibm.com/infocenter/zos/v1r9/topic/com.ibm.zos.r9.idau100/u1441.htm#u1441
This is not the direction I would recommend as the way to provide your best solution.
Since you might like to replace a variable name or a formula, with something wider, program lines could become wider than the original.
I would recommend writing a new pds(E) with variable length records supporting up to the normal 255 width default on other platforms.
Once you have reviewed the resulting pds(e), [ use the "superce" compare utility to reduce the compare time ] swap original/new names.
Super Contributor
Super Contributor
Posts: 3,174

Re: Macro to read and edit PDS members

Note that there are limitations to PROC SOURCE, if for other than processing the directory -- recommend read the directory and then input/parse/change/output your PDS members each in an individual DATA step.

Also, there is another similar post/thread here in the EG forum:

http://support.sas.com/forums/thread.jspa?threadID=2518


Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 3 replies
  • 436 views
  • 0 likes
  • 3 in conversation