BookmarkSubscribeRSS Feed
DPraba79
Calcite | Level 5
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?
2 REPLIES 2
deleted_user
Not applicable
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
deleted_user
Not applicable
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. .

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 848 views
  • 0 likes
  • 2 in conversation