setting views with PROC DS2

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

setting views with PROC DS2

Hi, I am trying to get proc ds2 to work for setting a SAS view from a library (the engine of the view is SQLVIEW) but I can't go past the set statement and I can't understand why. I am running sas 9.3

It's as if SAS cannot find the libname, albeit I am sure i defined it correctly.

libname _all_ clear;

data class;
set sashelp.class;
run;

/* this works */
proc ds2;
data _null_;
	method run();
      set class;
   end;
run;
quit;

/* this does not work, but it's ok */
proc ds2;
data _null_;
	method run();
      set sashelp.class;
   end;
run;
quit;

libname mylib base 'path/to/my/lib/with/views/in/it';
/* this runs ok, as the view exists */
proc contents data=mylib.myview; run; 

/* this DOES NOT work, and it's driving me mad */
proc ds2;
data _null_;
	method run();
      set mylib.myview;
   end;
run;
quit;

Any pointer would be appreciated, thanks!


Accepted Solutions
Solution
‎09-05-2017 10:56 AM
Trusted Advisor
Posts: 1,301

Re: setting views with PROC DS2

To use a sas data set view in the DS2 Procedure is must be created by the FEDSQL Procedure statement CREATE VIEW.  A view using the SQL Procedure will not be compatible and neither will a view created by the data statement VIEW= argument.

 

* no access to sashelp from fedsql/ds2;
data class;
set sashelp.class;
run;

proc sql;
create view v_class
         as
	 select *
	   from class ;
quit;

proc fedsql;
    create view v_class2 
             as 
         select * 
           from class ;
quit;

data v_class3 / view=v_class2;
set class;
run;

proc ds2;
    * fails... cannot use PROC SQL view;
    data class2;
        method run();
            set v_class;
		end;
    enddata;
    run;
    * fails... cannot use DATA Statement view;
    data class2(overwrite=yes);
        method run();
            set v_class3;
		end;
    enddata;
    run;
    * success... can use FEDSQL view;
    data class2(overwrite=yes);
        method run();
            set v_class2;
		end;
    enddata;
    run;
quit;

View solution in original post


All Replies
Solution
‎09-05-2017 10:56 AM
Trusted Advisor
Posts: 1,301

Re: setting views with PROC DS2

To use a sas data set view in the DS2 Procedure is must be created by the FEDSQL Procedure statement CREATE VIEW.  A view using the SQL Procedure will not be compatible and neither will a view created by the data statement VIEW= argument.

 

* no access to sashelp from fedsql/ds2;
data class;
set sashelp.class;
run;

proc sql;
create view v_class
         as
	 select *
	   from class ;
quit;

proc fedsql;
    create view v_class2 
             as 
         select * 
           from class ;
quit;

data v_class3 / view=v_class2;
set class;
run;

proc ds2;
    * fails... cannot use PROC SQL view;
    data class2;
        method run();
            set v_class;
		end;
    enddata;
    run;
    * fails... cannot use DATA Statement view;
    data class2(overwrite=yes);
        method run();
            set v_class3;
		end;
    enddata;
    run;
    * success... can use FEDSQL view;
    data class2(overwrite=yes);
        method run();
            set v_class2;
		end;
    enddata;
    run;
quit;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 88 views
  • 0 likes
  • 2 in conversation