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

I need to create a Data Step View for an existing dataset. This view should not be require that one assign the physical path of the existing dataset to a specific Libref.

I need Data Step equivalent of following PROC SQL View:

Libname ViewOut "<physical path of view output library>" disp=shr;

PROC SQL 

         CREATE VIEW ViewOut.DataSetName as

              SELECT * FROM XYZ123.DataSetName

              USING LIBNAME  XYZ123 "<physical path of existing output dataset>"

              DISP=SHR WAIT=999;

QUIT;

 

In the above PROC SQL View, the physical path of the dataset is included within the view, so, if the one has access to the view, he/she does not need to know where the actual dataset is.

 

Thanks in anticipation!

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

A data step view is compiled before being stored as a .sas7bvew file, so it can't be dynamic after that, with the exception of changing the physical path for a libname. So what you want to do is not possible.

SQL views, OTOH, are stored as program code and executed with proc sql at runtime.

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

I don't believe that is possible as such in SAS, they only implement ANSI SQL.  What is it your trying to do, from that code you just create a view of a dataset, which is database thinking.  SAS references data with libnames, so effectively the same code would be:

libname dataloc "<physical_path>";

 

I.e. point the library reference to where the data is.  That is all you need.  If you need further complicated views then you need the libref and the code.

Kurt_Bremser
Super User

A data step view is compiled before being stored as a .sas7bvew file, so it can't be dynamic after that, with the exception of changing the physical path for a libname. So what you want to do is not possible.

SQL views, OTOH, are stored as program code and executed with proc sql at runtime.

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 701 views
  • 0 likes
  • 3 in conversation