DATA Step, Macro, Functions and more

Can sas view be dynamic

Accepted Solution Solved
Reply
Regular Contributor
Posts: 242
Accepted Solution

Can sas view be dynamic

I have following sas view with where condition. First time I pass the value of User_date as 1Jan2016 and view become fixed. 

 

Now if I change the user date to 2Jan2016, it shows me 1Jan data. I tried it with diferent session but view is resulting in 1 Jan records.

 

I want to have view with flexibility to show me different record if I change the value of User_date.

 

proc sql;

create view temp_view as

select *

from table1 where RUN_DATE = &USER_DATE;

quit;

 

 


Accepted Solutions
Solution
‎07-07-2016 11:26 PM
Super User
Posts: 9,691

Re: Can sas view be dynamic

proc sql;
create view temp_view as
select *
from sashelp.class where sex=symget('USER_DATE');
quit;


%let USER_DATE=F;
proc print data=temp_view ;run;





%let USER_DATE=M;
proc print data=temp_view ;run;

View solution in original post


All Replies
Super User
Posts: 5,260

Re: Can sas view be dynamic

I don't have SAS at my fingertips right to test, bet perhaps symget() could work?
If not, store you dynamic value in a table and use it in a inner join/sub query in the view.
Data never sleeps
Solution
‎07-07-2016 11:26 PM
Super User
Posts: 9,691

Re: Can sas view be dynamic

proc sql;
create view temp_view as
select *
from sashelp.class where sex=symget('USER_DATE');
quit;


%let USER_DATE=F;
proc print data=temp_view ;run;





%let USER_DATE=M;
proc print data=temp_view ;run;
☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 243 views
  • 2 likes
  • 3 in conversation