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

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1 reply
  • 766 views
  • 0 likes
  • 2 in conversation