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!
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;
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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: