<?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: Call sas table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Call-sas-table/m-p/817318#M322611</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;This macro prints a table if the table is empty.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Huh?&amp;nbsp; You appear to using table in two different meanings in the same sentence.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you saying it makes a report if the dataset is empty?&lt;/P&gt;</description>
    <pubDate>Thu, 09 Jun 2022 15:39:49 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-06-09T15:39:49Z</dc:date>
    <item>
      <title>Call sas table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-sas-table/m-p/817309#M322603</link>
      <description>Hello folks, I have a sas data set name as a test If I have a test data set available then it should be call same table If table doesn't exist then  I want to create the blank table with some columns &lt;BR /&gt;Thanks</description>
      <pubDate>Thu, 09 Jun 2022 14:55:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-sas-table/m-p/817309#M322603</guid>
      <dc:creator>harshpatel</dc:creator>
      <dc:date>2022-06-09T14:55:10Z</dc:date>
    </item>
    <item>
      <title>Call Sas table if it is available or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-sas-table/m-p/817302#M322612</link>
      <description>Hello folks, &lt;BR /&gt;I have a sas data set name as a test&lt;BR /&gt;If I have a test data set available then it should be call same table&lt;BR /&gt;If table doesn't exist then also I want to call the blank table like test&lt;BR /&gt;Thanks</description>
      <pubDate>Thu, 09 Jun 2022 14:36:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-sas-table/m-p/817302#M322612</guid>
      <dc:creator>harshpatel</dc:creator>
      <dc:date>2022-06-09T14:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: Call sas table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-sas-table/m-p/817314#M322607</link>
      <description>&lt;P&gt;Details when programming are important. Such as are the variables to be create the same every time that Test does not exist has to be used? Do they have the same properties of type(numeric or character), length (especially for character variables)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2022 15:22:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-sas-table/m-p/817314#M322607</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-06-09T15:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: Call sas table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-sas-table/m-p/817315#M322608</link>
      <description>It could be any numeric or character&lt;BR /&gt;Basically I need to create blank table with some columns if table doesn't exist</description>
      <pubDate>Thu, 09 Jun 2022 15:25:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-sas-table/m-p/817315#M322608</guid>
      <dc:creator>harshpatel</dc:creator>
      <dc:date>2022-06-09T15:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: Call sas table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-sas-table/m-p/817317#M322610</link>
      <description>&lt;P&gt;This macro prints a table if the table is empty.&lt;/P&gt;
&lt;P&gt;You can modify the code, to remove the proc print and put your create table statements there instead.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p011imau3tm4jen1us2a45cyenz9.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p011imau3tm4jen1us2a45cyenz9.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
x=1;
run;
data two;
stop;
run;

%macro drive(dsn);
%let dsid=%sysfunc(open(&amp;amp;dsn));
    
 %if &amp;amp;dsid ne 0 %then %do;
  %let cnt=%sysfunc(attrn(&amp;amp;dsid,nlobs));
  %let rc=%sysfunc(close(&amp;amp;dsid));
   %if &amp;amp;cnt ne 0 %then %do;

/*What to do if data set exists*/
    proc print data=&amp;amp;dsn;
     title "This is data from data set &amp;amp;dsn"; 
    run;
   %end;
   %else %do;
/*What to do if data set does not exist*/
    data _null_;
     title;
     file print;
     put _page_;
     put "Data set &amp;amp;dsn is empty.";
    run;
   %end;
 %end;
 %else %put &amp;amp;dsn cannot be open.;
   
%mend drive;
%drive(one)
%drive(two)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259069"&gt;@harshpatel&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hello folks, I have a sas data set name as a test If I have a test data set available then it should be call same table If table doesn't exist then I want to create the blank table with some columns &lt;BR /&gt;Thanks&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2022 15:32:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-sas-table/m-p/817317#M322610</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-06-09T15:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: Call sas table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-sas-table/m-p/817318#M322611</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;This macro prints a table if the table is empty.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Huh?&amp;nbsp; You appear to using table in two different meanings in the same sentence.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you saying it makes a report if the dataset is empty?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2022 15:39:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-sas-table/m-p/817318#M322611</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-09T15:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: Call Sas table if it is available or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-sas-table/m-p/817320#M322613</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259069"&gt;@harshpatel&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hello folks, &lt;BR /&gt;I have a sas data set name as a test&lt;BR /&gt;If I have a test data set available then it should be call same table&lt;BR /&gt;If table doesn't exist then also I want to call the blank table like test&lt;BR /&gt;Thanks&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It is not clear what you mean by "call".&amp;nbsp; Or for that matter "table".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you saying that if a dataset does not exist you want to create an empty one with that name?&lt;BR /&gt;Do you know the structure it should have?&lt;/P&gt;
&lt;P&gt;For example do you an existing dataset that you know will always exist that has the right structure?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have the name of the dataset in a macro variable, say DSNAME, and you have the template dataset available as TEMPLATE then do something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dsname=MYDS;
%if not %sysfunc(exist(&amp;amp;dsname)) %then %do;
data &amp;amp;dsname;
   stop;
   set template ;
run;
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;to create a new dataset with zero observations.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2022 15:49:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-sas-table/m-p/817320#M322613</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-09T15:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: Call sas table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-sas-table/m-p/817321#M322614</link>
      <description>&lt;P&gt;Slightly different approach&lt;/P&gt;
&lt;P&gt;/* create sample test */&lt;BR /&gt;data test;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%macro createtable(tab);&lt;BR /&gt;%if %sysfunc(exist(&amp;amp;tab))=1 %then /* check if table exists */&lt;BR /&gt;%do;&lt;/P&gt;
&lt;P&gt;data &amp;amp;tab;&lt;BR /&gt;set &amp;amp;tab;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%end;&lt;BR /&gt;%else&lt;BR /&gt;%do; /*if table does not exist create a generic table, adjust to your needs*/&lt;/P&gt;
&lt;P&gt;data new;&lt;BR /&gt;length var1 - var5 $ 10;&lt;BR /&gt;length var6 - var10 8;&lt;BR /&gt;do i = 1 to 5;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;drop i;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%end;&lt;BR /&gt;%mend createtable;&lt;/P&gt;
&lt;P&gt;options mprint;&lt;/P&gt;
&lt;P&gt;%createtable(test)&lt;BR /&gt;%createtable(test2)&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2022 16:14:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-sas-table/m-p/817321#M322614</guid>
      <dc:creator>JOL</dc:creator>
      <dc:date>2022-06-09T16:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: Call sas table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-sas-table/m-p/817324#M322617</link>
      <description>Thanks, got the solution</description>
      <pubDate>Thu, 09 Jun 2022 16:28:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-sas-table/m-p/817324#M322617</guid>
      <dc:creator>harshpatel</dc:creator>
      <dc:date>2022-06-09T16:28:16Z</dc:date>
    </item>
  </channel>
</rss>

