<?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 Re: Automated Replacement of View with Table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/714129#M220417</link>
    <description>&lt;P&gt;I would be strongly tempted to examine Libraries for parallel processes or named files. Have your views in one library and the report or generated data sets in a different library. Then name collisions aren't an issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another possibility would be to enforce a stronger naming pattern like all the View names start with V and the data sets with DS or similar.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Mixing types with the same name is, as you have found, a recipe for confusion and extra work if not potential disasters. If these don't fit the bill then perhaps an examination of what choices were made that are creating the situation.&lt;/P&gt;</description>
    <pubDate>Mon, 25 Jan 2021 23:35:17 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-01-25T23:35:17Z</dc:date>
    <item>
      <title>Automated Replacement of View with Table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/714111#M220411</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;
&lt;P&gt;Does anyone know of an option or other mechanism - documented/supported or not - that makes a recent SAS version replace views with same named tables.&lt;/P&gt;
&lt;P&gt;What I would like to be able to do is to execute code as below.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create view class as
  select *
  from sashelp.class
  ;
quit;&lt;BR /&gt;
&lt;BR /&gt;/* data step or SQL create table */
data class;
  set sashelp.class;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Background&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I'm working in a big environment with multiple development streams in parallel. All the code is version controlled via git.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For each new project a new branch gets created and then pulled into a project folder on the file system. For the data there is a script which creates views in the projects pointing to a single source of physical data (SAS files - data volumes are significant). So far so good and this works really well.&lt;/P&gt;
&lt;P&gt;The challenge is: When it comes to changing and testing programs in a project then these programs create tables as output - but in the destination within the project there are now already same named views. It's not hard to just delete these views manually for unit testing but when it comes to running a whole flow for regression testing then identifying all the target tables/views and first delete them manually is rather inconvenient.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2021 22:46:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/714111#M220411</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-01-25T22:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Replacement of View with Table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/714129#M220417</link>
      <description>&lt;P&gt;I would be strongly tempted to examine Libraries for parallel processes or named files. Have your views in one library and the report or generated data sets in a different library. Then name collisions aren't an issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another possibility would be to enforce a stronger naming pattern like all the View names start with V and the data sets with DS or similar.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Mixing types with the same name is, as you have found, a recipe for confusion and extra work if not potential disasters. If these don't fit the bill then perhaps an examination of what choices were made that are creating the situation.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2021 23:35:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/714129#M220417</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-25T23:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Replacement of View with Table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/714135#M220422</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;When it comes to changing and testing programs in a project then these programs create tables as output - but in the destination&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Just to be clear on what's happening:&lt;/P&gt;
&lt;P&gt;Is the issue that DEV code creates tables and PROD code uses views?&lt;/P&gt;
&lt;P&gt;Or that input and output folders are the same in a project?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If 1) then DEV code should never write in PROD folders. Use a concatenated library (pointing to several paths) where the production paths are listed last, and are read-only. The path(s) listed first will receive all DEV files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If 2) why is the PROD code and the DEV code different? (one creates views and one crates tables)&lt;/P&gt;
&lt;P&gt;And why overwrite an input table with an output of the same name?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 01:06:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/714135#M220422</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-01-26T01:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Replacement of View with Table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/714158#M220431</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your answers. It appears I wasn't able to fully explain the situation.&lt;/P&gt;
&lt;P&gt;Sooo... Everything Production is under a top folder. Under this folder are sub-folders for code and data.&lt;/P&gt;
&lt;P&gt;For a new release one creates a copy of this Production folder structure which replicates the folder structure under a Development folder. The code sub-folder contains all the production code to start with, the data sub-folder contains views pointing to the production data instead of a full copy of the production data (because the data volumes are significant). The views in the Dev area must have the same names than the tables in the Prod area for the code in the Dev area to work without any change. The views in the Dev area look like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* rootpath set when initiating SAS */
%let rootpath=&amp;lt;some path&amp;gt;;

/* libnames created via init macro always on top of a program */
libname staging "&amp;amp;rootpath/staging";

/* SQL view example. Created scripted as part of development project setup */
proc sql;
  create view staging.table_1 as
  select *
  using '&amp;lt;fully qualified path to prod data folder&amp;gt;/table_1.sas7bdat'
  ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Above allows for multiple development projects in parallel. Using git code changes from dev branches get then merged when moving into Test.&lt;/P&gt;
&lt;P&gt;Mostly things work already as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;proposes:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;If 1) then DEV code should never write in PROD folders. Use a concatenated library (pointing to several paths) where the production paths are listed last, and are read-only. The path(s) listed first will receive all DEV files.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I've done already is to create another data structure under the Dev folder - one set with the views and one set just with empty folders - and then amended then run as part of the init macro code which creates concatenated libraries (first pointing to the empty folder structure and then to the one with the views). This works as intended as long as there aren't any additional libnames in the code itself (as I want to unit test dev code that doesn't require any further changes before moving to higher environments).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope above explains the situation I'm facing and why I'm looking for an option which changes SAS default behaviour (not very hopeful but felt I ask before just accepting that there isn't such an option).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 05:49:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/714158#M220431</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-01-26T05:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Replacement of View with Table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/714200#M220462</link>
      <description>I still think you could use a libname pointing to (&amp;amp;devlib_readwrite &amp;amp;_prdlib_readonly) rather than creating views, no?&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Jan 2021 09:47:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/714200#M220462</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-01-26T09:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Replacement of View with Table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/714222#M220475</link>
      <description>Maybe you could query the " Dictionary.views " before creating a dataset with same name.&lt;BR /&gt;If it exists, drop this view ?</description>
      <pubDate>Tue, 26 Jan 2021 11:33:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/714222#M220475</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-01-26T11:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Replacement of View with Table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/714403#M220549</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;What I've done already is to create another data structure under the Dev folder - one set with the views and one set just with empty folders - and then amended then run as part of the init macro code which creates concatenated libraries (first pointing to the empty folder structure and then to the one with the views).&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't understand why use views rather than use the prod folder at the end of the concatenated library.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 20:09:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/714403#M220549</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-01-26T20:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Replacement of View with Table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/714465#M220576</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;What I've done already is to create another data structure under the Dev folder - one set with the views and one set just with empty folders - and then amended then run as part of the init macro code which creates concatenated libraries (first pointing to the empty folder structure and then to the one with the views).&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't understand why use views rather than use the prod folder at the end of the concatenated library.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;True, the 2nd path in the concatenated library could directly point to the prod data - but it would be a further deviation of how stuff is configured at the site I'm working. Also: This is only a side story and doesn't address the issue with libnames in code (as I don't want to change them, add a path to them).&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 02:11:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/714465#M220576</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-01-27T02:11:58Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Replacement of View with Table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/714466#M220577</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Maybe you could query the " Dictionary.views " before creating a dataset with same name.&lt;BR /&gt;If it exists, drop this view ?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I've extended the %init macro with a post process which does something similar: Get a list of all the librefs defined and use the definitions to concatenate a path to it (in first position) which points to the empty data folder structure under my project folder. But this doesn't resolve the issue I'm facing with libnames defined in jobs - libnames I don't want to change because then I would have to modify code after unit testing.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 02:16:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/714466#M220577</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-01-27T02:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Replacement of View with Table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/714486#M220587</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;doesn't address the issue with libnames in code&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;libnames in production code are best avoided I reckon.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's not always the best strategy, so they could be standardised and contain variables such as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;env (values PRD or DEV) and &amp;amp;project (folder/tree path)&lt;/P&gt;
&lt;P&gt;and look like&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; libname CCFA "&amp;amp;svrdrv\PRD\&amp;amp;project";&amp;nbsp; &lt;/FONT&gt;in PROD&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and be customised to overwrite the PROD library in DEV:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; libname CCFAPRD "&amp;amp;svrdrv\PRD\&amp;amp;project" access=readonly;&amp;nbsp;&lt;/FONT&gt; in PROD&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; libname CCFA ("&amp;amp;svrdrv\DEV\&amp;amp;project" CCFAPRD );&amp;nbsp;&lt;/FONT&gt; in DEV&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To go back to the original question, there is no automatic way that I know to remove views when &lt;SPAN&gt;homonymous&amp;nbsp;&lt;/SPAN&gt;data sets are created.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 07:29:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/714486#M220587</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-01-27T07:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Replacement of View with Table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/720712#M223276</link>
      <description>&lt;P&gt;Apologies to only respond now.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Creating concatenated libraries allows me to unit test my code without having to create all the views in my development area. For regression testing I still need the view due to some process I don't touch creating additional libraries which need the views to exist (as they expect the data to be "replicated" in my development area).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So not really a 100% solution but something I can work with practically. Shame that there is no way to instruct SAS to deal with views as if they were tables when it comes to replacing a target table/view.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Feb 2021 05:49:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automated-Replacement-of-View-with-Table/m-p/720712#M223276</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-02-21T05:49:51Z</dc:date>
    </item>
  </channel>
</rss>

