BookmarkSubscribeRSS Feed
valleet
Calcite | Level 5

Dear all,

 

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 ....

 

proc sql;

create view as dsNb&nb as select .....;

quit;

 

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

the noexec.

 

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,

Thierry

 

 

6 REPLIES 6
Astounding
PROC Star

Have  you tried changing "view as" to "view" (removing the first "as")?

 

mnjtrana
Pyrite | Level 9

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;

Cheers from India!

Manjeet
DanielSantos
Barite | Level 11

Hi.

 

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

 

proc sql;

     describe view libname.viewname;

quit;

 

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

valleet
Calcite | Level 5

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.



Thierry







valleet
Calcite | Level 5

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.



Thierry





LinusH
Tourmaline | Level 20
I'm not really following, what is the actual problem?
When you define views corresponding SAS files are created but they contain no data, just the definition ("meta data"). Can't see any problem hee since those very light weight. The problem will problem will more likely to occur when calling your views, it's not very efficient to call the same table that many times, but that will show later...
Data never sleeps

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 6 replies
  • 875 views
  • 0 likes
  • 5 in conversation