SAS:自动执行文件的计时/将格式应用于数据集以供查看
这是背景。 抱歉这么长:
我为 3 个不同的项目进行 SAS 编程。 每个项目都有自己的主项目文件夹。 每个主项目文件夹都包含一个格式文件夹(其中包含格式目录),然后是几个其他文件夹,每个文件夹都包含程序和数据集。 我的大部分工作都是以批处理模式进行的,所以SAS通常是不打开的。 不过,有时我想在 SAS 中打开数据集来查看特定的内容。 当我执行此操作时,SAS 不知道在哪里查找适当的格式目录,因为格式目录永远不会与数据集位于同一文件夹中。 因此,我当前使用指定 nofmterr
选项的 autoexec.sas 文件,以便打开我的数据集。
不过,我真的很希望能够以适当的格式打开我的数据集。 我编写了一个不同的 autoexec 程序,它使用一个对话框窗口,询问我正在处理哪个项目,然后相应地设置 fmtsearch
选项。 如果我想先打开 SAS,然后打开数据集,这非常有用。 但是,如果 SAS 尚未启动并运行,并且我尝试通过双击打开数据集,则会发生以下情况:autoexec 文件开始运行,然后 SAS 尝试在 autoexec 文件完成运行之前打开数据集。 因此,如果我设置了 nofmterr
,则数据集将在没有格式的情况下打开,或者如果我没有设置 nofmterr
,则数据集根本不会打开。
所以这是我的问题:有没有办法让 SAS 等到 autoexec 文件完成运行后再尝试打开数据集? 或者,还有其他方法可以解决这个问题吗? (我不想将所有 3 个格式文件添加到 fmtsearch
选项中,因为不同的项目可能具有相同名称的不同格式。)
Here's the background. I'm sorry it's so long:
I do SAS programming for 3 different projects. Each project has its own main project folder. Each main project folder contains a formats folder (which contains the format catalog), and then several other folders, each of which contains programs and datasets. I do most of my work in batch mode, so SAS is usually not open. Occasionally, though, I want to open a dataset in SAS to look at something in particular. When I do this, SAS does not know where to look for the appropriate format catalog, because the format catalogs are never in the same folder as the datasets. So I currently use an autoexec.sas file that specifies the nofmterr
option, so that my datasets will open.
I would really like, though, to be able to open my datasets with the appropriate formatting. I wrote a different autoexec program that uses a dialog window that asks me which project I am working on and then sets the fmtsearch
option accordingly. This works great if I want to first open SAS, and then open a dataset. But if SAS is not already up and running, and I try to open a dataset by double-clicking on it, here's what happens: the autoexec file starts running, then SAS tries to open the dataset before the autoexec file has finished running. So if I have nofmterr
set, the dataset will open without formats, or if I don't have nofmterr
set, the dataset won't open at all.
So here's my question: Is there a way to get SAS to wait until the autoexec file finishes running before it tries to open the dataset? Or, is there another way around the problem? (I don't want to add all 3 format files to the fmtsearch
option, because different projects might have different formats with the same name.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于数据集是在没有事先运行任何代码的情况下打开的,因此这变得非常困难。 是否可以将数据集作为代码的参数打开。 我设想这样的事情:
您的代码“opends.sas”将包含您的项目的所有相关格式信息。
您甚至可以编写一个包含上述所有预定义内容的脚本(bash 或批处理,具体取决于操作系统),并且可以使用数据集作为参数来调用该脚本。
我知道这看起来很麻烦,但这是我根据您的描述提出的第一个解决方案。
--添加了 20090218
opends.sas 脚本应该接受 sysparm 变量,并且根据操作系统,它应该打印数据集或发出打开数据集的命令。
Since the dataset is opening without any code running before hand, this becomes quiet difficult. Is it possible to open the dataset as a parameter of a code. I envision something like this:
Your code "opends.sas" would include all of the relavent formatting information for your project.
You could even write a script (bash or batch depending on OS) that has all of the above predefined and you could call the script with the dataset as a parameter.
I know this seems cumbersome, but it is the first solution I could come up with based on your description.
--Added 20090218
The opends.sas script should take in a sysparm variable and depending on the operating system, it should print the dataset or issue a command to open the dataset.