Desktop productivity for business analysts and programmers

How to read PS file has PDS name ?

Reply
Contributor
Posts: 34

How to read PS file has PDS name ?

Hi Team,

I have a situation like, One PS file has list of PDS names. In SAS , i want to read this PS file first, and then in first record actually first PDS name, I have to read all the member in the first PDS, after read the second line, which is Second PDS name, then i have to read all the members in the second PDS.
I have tried FileVar also, but not working for my scenario. Could you please help me?
N/A
Posts: 0

Re: How to read PS file has PDS name ?

What does your code look like so far?

filevar should work for you.
I know, because I did something like that for Y2K compliance investigation.

Of course, you may be better advised to take your query to Customer Support for specific help

Good luck

PeterC
N/A
Posts: 0

Re: How to read PS file has PDS name ?

SAS provides many paths to a solution. There is no one right answer.

One way would be to use the filevar option. It is not working for you because you probably aren't controlling it properly. You will need to use it inside of some conditional statements, and you will also need to use the END= option with it to know when to change the filevar variable.

Another way would be to put the processing you want to do in a macro, and then use a data step to read the PS file and use the CALL EXECUTE function to call the macro and pass it the name of the PDS you want to use/read

Another way would be to read the PS file and create a long macro variable with all the PDS names concatenated (space delimited) together.

One way to use the filevar is to use one datastep to read both the PS file and the PDS files.

Another way use the filevar is to use two datasteps, one to read the PS file and another to read the PDS files.

In the second method above, using CALL EXECUTE to call a macro, the macro could either use the filevar option, or use the filename directly.

Instead of CALL EXECUTE calling a macro directly, the dataset could compose a one line macro call, save it to a dynamically generated SAS file, and then the CALL EXECUTE could %include that file.

Just so you know, I have used all these methods at one time or another to solve various problems.

SAS is a data centric language, not process and control centric; but, you still have to be careful about execution order, when something is executed, when a value is changed. The most important thing is to read, read, read, and then to think about what you want to do and then read some more. Interspersed with that are experiments (I use the term "play" -- play.sas, %macro play; ) to make sure you (I) understand what I (you) just read. .
Ask a Question
Discussion stats
  • 2 replies
  • 106 views
  • 0 likes
  • 2 in conversation