BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
eagles_dare13
Obsidian | Level 7

I found this code snippet in our code base:

data _null;

    file aaa;

    filename = 'xxx_123' ;

        run;

%include aaa;

filename aaa clear;

Will this run the macro xxx_123.sas and store the output in aaa and then clear it

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

No. Here is what it will do.

1) It will make a dataset name _NULL with one observation and one variable, FILENAME, with the value 'xxx_123'.

If the fileref AAA was defined before the data step then :

2A) it will be made empty since the data step writes nothing into it.

3A) it will then try to include the empty file as code and so nothing will happen.

4A) it will undefine the fileref AAA.

Otherwise

  2B)  it will create an empty file named aaa.dat in the current working directory.

  3B)  it will try to include SAS statements from a file named aaa.sas.  Effect will vary based on whether such a file exists or not.

  4B) it will get a warning trying to undefine the fileref AAA.

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

No. Here is what it will do.

1) It will make a dataset name _NULL with one observation and one variable, FILENAME, with the value 'xxx_123'.

If the fileref AAA was defined before the data step then :

2A) it will be made empty since the data step writes nothing into it.

3A) it will then try to include the empty file as code and so nothing will happen.

4A) it will undefine the fileref AAA.

Otherwise

  2B)  it will create an empty file named aaa.dat in the current working directory.

  3B)  it will try to include SAS statements from a file named aaa.sas.  Effect will vary based on whether such a file exists or not.

  4B) it will get a warning trying to undefine the fileref AAA.

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!

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
  • 1 reply
  • 927 views
  • 0 likes
  • 2 in conversation