<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic proc sql create view with dynamic sas.userid macro var in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10485#M817</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;we try to create a proc sql view that fetches data for each user individually,&lt;/P&gt;&lt;P&gt;Unfortunately, if we use &lt;SPAN style="color: #008000; font-size: 10pt; font-family: Courier New;"&gt;%str(%')&amp;amp;sysuserid.%str(%') &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 10pt; font-family: Courier New;"&gt;the user ID of the creator of this view gets replaced and is fixed.&lt;BR /&gt;How would we create a view that is creating a dynamic WHERE clause?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql ;&lt;BR /&gt;connect to oracle as oradb (user='sas' password='{xxxxx&lt;BR /&gt;path=xxxadas);&lt;/P&gt;&lt;P&gt;create view mysas.ph_filtered_facts as&lt;BR /&gt;select *&lt;BR /&gt;from connection to oradb&lt;BR /&gt;(&lt;BR /&gt;SELECT FAKT FROM DEV.FAK&lt;BR /&gt;WHERE Wer IN &lt;BR /&gt;(SELECT Wer FROM DEV.vk WHERE SK = 1 AND&lt;BR /&gt;VK IN&lt;BR /&gt;(SELECT VK FROM DEV.SASLOGINS WHERE SASLOGIN = %str(%')&amp;amp;sysuserid.%str(%') ))&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;run;&lt;BR /&gt;disconnect from oradb;&lt;BR /&gt;quit;&lt;BR /&gt;run;&lt;BR /&gt;proc print data=pt_example;&lt;BR /&gt;title "Using SQL Pass-Through";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We also tried:&lt;/P&gt;&lt;P&gt;%str(%')symget(_metauser)%str(%') ))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 15 Sep 2011 14:10:04 GMT</pubDate>
    <dc:creator>metalray</dc:creator>
    <dc:date>2011-09-15T14:10:04Z</dc:date>
    <item>
      <title>proc sql create view with dynamic sas.userid macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10485#M817</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;we try to create a proc sql view that fetches data for each user individually,&lt;/P&gt;&lt;P&gt;Unfortunately, if we use &lt;SPAN style="color: #008000; font-size: 10pt; font-family: Courier New;"&gt;%str(%')&amp;amp;sysuserid.%str(%') &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 10pt; font-family: Courier New;"&gt;the user ID of the creator of this view gets replaced and is fixed.&lt;BR /&gt;How would we create a view that is creating a dynamic WHERE clause?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql ;&lt;BR /&gt;connect to oracle as oradb (user='sas' password='{xxxxx&lt;BR /&gt;path=xxxadas);&lt;/P&gt;&lt;P&gt;create view mysas.ph_filtered_facts as&lt;BR /&gt;select *&lt;BR /&gt;from connection to oradb&lt;BR /&gt;(&lt;BR /&gt;SELECT FAKT FROM DEV.FAK&lt;BR /&gt;WHERE Wer IN &lt;BR /&gt;(SELECT Wer FROM DEV.vk WHERE SK = 1 AND&lt;BR /&gt;VK IN&lt;BR /&gt;(SELECT VK FROM DEV.SASLOGINS WHERE SASLOGIN = %str(%')&amp;amp;sysuserid.%str(%') ))&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;run;&lt;BR /&gt;disconnect from oradb;&lt;BR /&gt;quit;&lt;BR /&gt;run;&lt;BR /&gt;proc print data=pt_example;&lt;BR /&gt;title "Using SQL Pass-Through";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We also tried:&lt;/P&gt;&lt;P&gt;%str(%')symget(_metauser)%str(%') ))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2011 14:10:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10485#M817</guid>
      <dc:creator>metalray</dc:creator>
      <dc:date>2011-09-15T14:10:04Z</dc:date>
    </item>
    <item>
      <title>proc sql create view with dynamic sas.userid macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10486#M818</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could do this before the proc sql step:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt; call symput('usr',"'"||"&amp;amp;sysuserid"||"'");&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then change saslogin=&amp;amp;usr in proc sql.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2011 14:43:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10486#M818</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-09-15T14:43:47Z</dc:date>
    </item>
    <item>
      <title>proc sql create view with dynamic sas.userid macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10487#M819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi FriedEgg,&lt;/P&gt;&lt;P&gt;a good try but the view is still not dynamic. The describe statement still contains the creators user ID, even when executing the describe with other users&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;call symput('usr',"'"||"&amp;amp;sysuserid"||"'");&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql ;&lt;BR /&gt;connect to oracle as oradb (user='....' password='.....'&lt;BR /&gt;path='.....');&lt;BR /&gt;create view mysas.ph_filtered_facts as&lt;BR /&gt;select *&lt;BR /&gt;from connection to oradb&lt;BR /&gt;(&lt;BR /&gt;SELECT FAKT FROM DEV.FAKTEN&lt;BR /&gt;WHERE Wer IN &lt;BR /&gt;(SELECT Wer FROM DEV.vk WHERE SK = 1 AND&lt;BR /&gt;VK IN&lt;BR /&gt;(SELECT VK FROM DEV.SASLOGINS WHERE SASLOGIN = &amp;amp;usr ))&lt;BR /&gt;);&lt;BR /&gt;run;&lt;BR /&gt;disconnect from oradb;&lt;BR /&gt;quit;&lt;BR /&gt;run;&lt;BR /&gt;/*also tried: (SELECT VK FROM DEV.SASLOGINS WHERE SASLOGIN = %str(%')&amp;amp;sysuserid.%str(%') ))*/&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*&lt;BR /&gt;proc sql;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; describe view mysas.ph_filtered_facts&lt;BR /&gt;/*Result*/&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select *&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from connection to oradb &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* dbms=oracle, connect options=(user='.....' password=XXXXX path='.....') */ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ( SELECT FAKT FROM DEV.FAKTEN WHERE Wer IN (SELECT Wer FROM DEV.vk WHERE SK = 1 AND &lt;BR /&gt;VK IN (SELECT VK FROM DEV.SASLOGINS WHERE SASLOGIN = 'S39' )) );&lt;BR /&gt;*/&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2011 15:28:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10487#M819</guid>
      <dc:creator>metalray</dc:creator>
      <dc:date>2011-09-15T15:28:42Z</dc:date>
    </item>
    <item>
      <title>proc sql create view with dynamic sas.userid macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10488#M820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How are you running the script as different user?&amp;nbsp; Did you check that &amp;amp;sysuserid is showing the expected user appropriatly during your runs?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2011 15:37:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10488#M820</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-09-15T15:37:49Z</dc:date>
    </item>
    <item>
      <title>proc sql create view with dynamic sas.userid macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10489#M821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I run it in EG, changing the connection profile.&lt;BR /&gt;I also use the view in an information map,changing connection profiles, still one and the same result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put &amp;amp;sysuserid; /* shows user id */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With the describe statement, I check how the view is defined for each user,&lt;BR /&gt;besides that, I also know the data, and that must be different for each user&lt;BR /&gt;but it is not, always shows S39.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; describe view mysas.ph_filtered_facts;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; /* still shows the user of the creator of the view,S39 , hence wrong data when I use user SDW */&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2011 15:49:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10489#M821</guid>
      <dc:creator>metalray</dc:creator>
      <dc:date>2011-09-15T15:49:36Z</dc:date>
    </item>
    <item>
      <title>proc sql create view with dynamic sas.userid macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10490#M822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What authentication mode are you using to spawn the conncetions, does each profile use the same user?&amp;nbsp; &amp;amp;sysuserid is the system user, so it should be equal to the value of the user that performs the login to that session.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2011 16:01:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10490#M822</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-09-15T16:01:17Z</dc:date>
    </item>
    <item>
      <title>proc sql create view with dynamic sas.userid macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10491#M823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is it necessary to use SQL in pass-thru mode? If you were able to write it directly against the oracle database (i.e. it'd have to be linked using libname) then you could use SYMGET() in your view definition instead.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2011 16:29:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10491#M823</guid>
      <dc:creator>DF</dc:creator>
      <dc:date>2011-09-15T16:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql create view with dynamic sas.userid macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10492#M824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@FriedEgg,What do you mean?&lt;BR /&gt;The "connect to oracle as oradb (user='....' password='.....' path='.....'); is always the same users" is obviously always&lt;BR /&gt;the same users, its the schema that contains the oracle tables that I use in the SQL statement.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I am a bit worried that there is no straight answer to that. Has none thought of using SQL PassThrough with the current user ID before?&lt;BR /&gt;FriedEgg, I am aware what the sysuserid is and I see that the %put &amp;amp;sysuserid; shows me the correct one. &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If I execute as S39 it shows S39, if I execute as SDW is shows SDW but the PROC SQL itself, always shows S39, the creator.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To me, the problem I have looks almost logical considering the logic that the SAS team applies when developing the great software for us.&lt;BR /&gt;When I execute the CREATE VIEW and substitute the sysuserid in the WHERE clause then that is nicely done during creation time&lt;BR /&gt;but that does not mean its a "dynamic" view.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@DF, good idea. I have an oracle (SAS ACCESS) library. but I am very reluctant to use a DATA step.&lt;/P&gt;&lt;P&gt;creating a SAS data set is not viable. one of the three tables contains a million rows and I&lt;/P&gt;&lt;P&gt;cant do that for every user. - hence the usage of a VIEW.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Sep 2011 07:01:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10492#M824</guid>
      <dc:creator>metalray</dc:creator>
      <dc:date>2011-09-16T07:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql create view with dynamic sas.userid macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10493#M825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;using a data step, I wonder how the nesting or join would work.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I cant loop through the millions of rows.&lt;/P&gt;&lt;P&gt;/*Nesting: &lt;A href="http://www.repole.com/dinosaur/fuzzymerge.html*/"&gt;http://www.repole.com/dinosaur/fuzzymerge.html*/&lt;/A&gt;&lt;BR /&gt;data mysas.PH_TEST_VIEW (keep=VK);&lt;BR /&gt;set dev.FAKTEN;&lt;BR /&gt;where WER IN ('S39');&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. DEV.SASLOGINS about 1000 rows&lt;BR /&gt;user login to vk groups&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. DEV.vk about 1000 rows&lt;BR /&gt;vk groups to individual Wer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. DEV.FAK millions of rows&lt;BR /&gt;individual Wer to all their data&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Sep 2011 10:24:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10493#M825</guid>
      <dc:creator>metalray</dc:creator>
      <dc:date>2011-09-16T10:24:37Z</dc:date>
    </item>
    <item>
      <title>proc sql create view with dynamic sas.userid macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10494#M826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assuming your db is linked in SAS as "Dev", I was thinking something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create view mysas.ph_filtered_facts as&lt;/P&gt;&lt;P&gt;select&lt;/P&gt;&lt;P&gt;fakt&lt;/P&gt;&lt;P&gt;from dev.fak&lt;/P&gt;&lt;P&gt;inner join dev.vk on fak.wer = vk.wer and vk.sk=1&lt;/P&gt;&lt;P&gt;inner join dev.saslogins on saslogins.vk = vk.vk&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;saslogins.login = symget('sysuserid');&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Obviously I can't test it, and I might have confused your table linkage - I was trying to remove the subqueries and I think SAS wouldn't deal with these very well!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Sep 2011 10:56:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10494#M826</guid>
      <dc:creator>DF</dc:creator>
      <dc:date>2011-09-16T10:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql create view with dynamic sas.userid macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10495#M827</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks to me like you are trying to reference a SAS macro variable in the code that is running in the database.&amp;nbsp; I do not think that is possible.&lt;/P&gt;&lt;P&gt;You might want to instead look for an ORACLE (or whatever your database is) function that can return the ORACLE userid.&amp;nbsp; But that might not match the userid values that are stored in your database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to do this on just the SAS side then you could use the SYMGET function in your view.&amp;nbsp; Try this program in SAS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc sql noprint ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; create view test1 as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select * from sashelp.class&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where name = symget('name')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let name=Mary ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set test1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; put name=;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let name=Philip;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set test1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; put name=;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Sep 2011 11:28:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10495#M827</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-09-16T11:28:00Z</dc:date>
    </item>
    <item>
      <title>proc sql create view with dynamic sas.userid macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10496#M828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's a good idea.&amp;nbsp; The below works on my Oracle setup:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT SYS_CONTEXT('USERENV','OS_USER') os_user from DUAL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could just plug that into the original SQL view and not bother with the macro variable, assuming it returns the correct user in your setup.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Sep 2011 11:34:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10496#M828</guid>
      <dc:creator>DF</dc:creator>
      <dc:date>2011-09-16T11:34:57Z</dc:date>
    </item>
    <item>
      <title>proc sql create view with dynamic sas.userid macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10497#M829</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks for your suggestions. I think I never got so many responses here.&lt;BR /&gt;First, yes, the Oracle User ID is very different from the user ID of the&lt;BR /&gt;view user. There is and will never be a match (@DF). We&lt;BR /&gt;have a thousand users for SAS but not a thousand Oracle USERIDs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@Tom, you pointed it out rightly, I cant use a SAS macro variable in the code that is&lt;BR /&gt;running on the database, hence my describe view statement always showed the&lt;BR /&gt;sasuserid of the creator of the view. I was hopeing this can be substituted at&lt;BR /&gt;runtime but obviously not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, we try to do a SAS DATA VIEW to allow putting the sysuserid of the individual executer&lt;BR /&gt;in the view and create a truly user-dependent-dynamic-view of data.&lt;/P&gt;&lt;P&gt;The data is quite large and I wonder how to efficiently link it using&lt;BR /&gt;a SAS DATA VIEW. I cant merge the tables, it will create millions of rows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Sep 2011 11:53:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10497#M829</guid>
      <dc:creator>metalray</dc:creator>
      <dc:date>2011-09-16T11:53:42Z</dc:date>
    </item>
    <item>
      <title>proc sql create view with dynamic sas.userid macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10498#M830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bob,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Oracle code I posted above returns the local OS username, rather than the oracle login.&amp;nbsp; In my case, even though I've logged into oracle as the user "SAS", it returns "DF" because that's the login I've used on the system sas is running on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tested it here using several logins and even though my code uses the same oracle username/password, the query returns the OS user I'm logged in as.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Sep 2011 12:22:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10498#M830</guid>
      <dc:creator>DF</dc:creator>
      <dc:date>2011-09-16T12:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql create view with dynamic sas.userid macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10499#M831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could see if SAS is smart enough to push the WHERE clause from the SAS side of the query into the database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;create view mysas.ph_filtered_facts as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; select *&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; from connection to oradb&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (select A.FAKT,C.SASLOGIN&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from DEV.FAKTEN A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , DEV.VK B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , DEV.SASLOGINS C&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where A.Wer = B.Wer&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and B.vk = C.vk&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and B.sk = 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; where SASLOGIN = symget('sysuserid')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Sep 2011 12:32:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10499#M831</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-09-16T12:32:26Z</dc:date>
    </item>
    <item>
      <title>proc sql create view with dynamic sas.userid macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10500#M832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@Tom,&lt;BR /&gt;good idea but with your SQL you are merging all the tables or&lt;BR /&gt;even creating some kind of cross/full join, something I cant do with&lt;BR /&gt;a million rows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@DF,&lt;BR /&gt;the idea with the OS User seems to work fine when opening the&lt;BR /&gt;View in EG but when using the view in an information map the&lt;BR /&gt;data returned is always nothing/empty. Please explain me,&lt;BR /&gt;why does OS_User work if the sas user does not exist on the&lt;BR /&gt;oracle database as a user?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Sep 2011 14:26:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10500#M832</guid>
      <dc:creator>metalray</dc:creator>
      <dc:date>2011-09-16T14:26:36Z</dc:date>
    </item>
    <item>
      <title>proc sql create view with dynamic sas.userid macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10501#M833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oracle knows the OS login for the connecting user, even though you use different credentials to log in.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure about the informaion map issue - I've only tested the view using EG under a few different accounts, having created it in a shared library.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Sep 2011 14:42:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10501#M833</guid>
      <dc:creator>DF</dc:creator>
      <dc:date>2011-09-16T14:42:02Z</dc:date>
    </item>
    <item>
      <title>proc sql create view with dynamic sas.userid macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10502#M834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi DF,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the connecting user is always the same as specified in&lt;/P&gt;&lt;P&gt;proc sql ;&lt;/P&gt;&lt;P&gt;connect to oracle as oradb (user='....' password='.....'&lt;/P&gt;&lt;P&gt;path='.....');&lt;/P&gt;&lt;P&gt;How can it be that Oracle knows the SAS executing user? - because&lt;/P&gt;&lt;P&gt;the executing user (sysuserid) is the one that will have to go in the WHERE clause&lt;/P&gt;&lt;P&gt;to only get the records for that specific user)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Sep 2011 07:39:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10502#M834</guid>
      <dc:creator>metalray</dc:creator>
      <dc:date>2011-09-19T07:39:46Z</dc:date>
    </item>
    <item>
      <title>proc sql create view with dynamic sas.userid macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10503#M835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not an Oracle expert, so I can't really answer for certain.&amp;nbsp; I suppose the OS user is just part of the information the Oracle driver passes from your system to the Oracle database - it makes sense that the information would be available as some setups would use this as the authentication method instead of specifying a username/passwords.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So while I log into Oracle as the user "oracle_user", so my oracle username/password gets sent, Oracle also gets told I'm logged into my local operating system as "DF" - and that's what goes into OS_USER.&amp;nbsp; When it's a SAS process that connects to Oracle, then Oracle is told the username that the SAS process is running under.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;There's lots of other information available using the same function: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://psoug.org/reference/sys_context.html"&gt;http://psoug.org/reference/sys_context.html&lt;/A&gt;&lt;SPAN&gt; might be worth having a look at.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is the pass-through view now working as desired?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Sep 2011 12:53:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10503#M835</guid>
      <dc:creator>DF</dc:creator>
      <dc:date>2011-09-19T12:53:52Z</dc:date>
    </item>
    <item>
      <title>proc sql create view with dynamic sas.userid macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10504#M836</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi DF,&lt;/P&gt;&lt;P&gt;works great. thanks a lot.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Sep 2011 12:26:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-create-view-with-dynamic-sas-userid-macro-var/m-p/10504#M836</guid>
      <dc:creator>metalray</dc:creator>
      <dc:date>2011-09-20T12:26:42Z</dc:date>
    </item>
  </channel>
</rss>

