01-11-2017 12:44 PM
I am using Enterprise 5.1.
I am trying to use "proc sql" and "create view" in a macro to create 100 views that I want to use later in my program one by one.
But, althouth It is written everywhere that the advantage of views is that they do no contain data and execute only when
called, my program actually creates the 100 files when I call this code:
%do %while ....
create view as dsNb&nb as select .....;
If I use the noexec option, then when I call the view later on, I do not get back the correct data set but the last data set without
Do someone knonw how to prevent SAS to create the data sets corresponding to the views as I run my macro ?
Thanks in advance for any help,
01-12-2017 01:25 AM - edited 01-12-2017 01:26 AM
You can write the sas view definitions to physical text files and then include the same in your code when required.
Below is one such example, you need to trim it as per your scenario.
filename sasview "c:\users\cxx\desktop\views.txt"; DATA _NULL_; set viewdef end=last; i=1; do while(i=100); i+1; file sasview mod; put 'proc sql;'; put 'create view ' viewname&nb 'as select'; put 'from ' col_name; put ' group by' grp_naame ';'; put 'order by' orderby_stat; put ';'; put 'quit;'; end; run; %inc sasview;
01-12-2017 05:01 AM
There should be no data inside those files (*.sas7vew) , only the definition of the view.
Should have just a few KB in size each.
If you have created the view with PROC SQL, you can issue the following command to check the view's definition
describe view libname.viewname;
Still if the those files are a problem check@mnjtrana solution to create them only at the time you need them.
Hope it helps.
Daniel Santos @ www.cgd.pt
01-12-2017 05:11 AM
Thhanks Astounding for your answer.
SAS definitively need the "as" there.
But now I think that what is stored in WORK is actually the view as the icone used is slightly different from the one use for data sets (although the Properties menu
indicates the object type as "data set".
So it seems so that my real problem is that the data sets corresponding to the views are output as data sets in the output panel, or whatever it is called, How could I avoid that.
01-12-2017 05:19 AM
Thanks Daniel for your answer.
Now I think that what is stored in WORK is actually the views as the icone used is slightly different from the one use for data sets (although the Properties menu
indicates the object type as "data set").
So it seems so that my real problem is that the data sets corresponding to the views are output as in the "output panel", or whatever it is called, Is it possible to avoid that.
01-13-2017 02:12 AM