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

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!

1 ACCEPTED SOLUTION

Accepted Solutions
FriedEgg
SAS Employee

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

1 REPLY 1
FriedEgg
SAS Employee

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;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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