<?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: Creating a dataset to capture all the observations of all tables in a program in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-dataset-to-capture-all-the-observations-of-all-tables/m-p/487507#M127048</link>
    <description>&lt;P&gt;Would it be easier to hit SASHELP.VCOLUMN instead and retrieve that information?&lt;/P&gt;
&lt;P&gt;Would it also make sense to pass two data set names in so it can compare the record counts and let you know if there's an issue?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/7111"&gt;@lei&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think having not programmed anything new lately has really deteriorated my skills.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a really long program. I want to create a secondary QA dataset which captures all the table names, observations numbers, variable numbers as the program is running. This way in each step, I can compare observation numbers to ensure that they all match. This needs to be automated which is why I am asking for help here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I do this in a macro? I know how to set up macro variables to do this (see below). However, I cannot figure out how to do it in a dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO OBSNVARS(DS);
%GLOBAL DSET NVARS NOBS;
%LET DSET=&amp;amp;DS;

/* OPEN DATA SET PASSED AS THE MACRO PARAMETER */
%LET DSID = %SYSFUNC(OPEN(&amp;amp;DSET)); /*1 IF DATASET EXISTS; 0 IF DATASET DOES NOT EXIST*/

/* IF THE DATA SET EXISTS, GET THE NUMBER OF OBSERVATIONS */
/* AND VARIABLES AND THEN CLOSE THE DATA SET */
%IF &amp;amp;DSID %THEN
%DO;
%LET NOBS =%SYSFUNC(ATTRN(&amp;amp;DSID,NOBS));
%LET NVARS=%SYSFUNC(ATTRN(&amp;amp;DSID,NVARS));
%LET RC = %SYSFUNC(CLOSE(&amp;amp;DSID));
%END;

/* OTHERWISE, WRITE A MESSAGE THAT THE DATA SET COULD NOT BE OPENED */
%ELSE %PUT OPEN FOR DATA SET &amp;amp;DSET FAILED - %SYSFUNC(SYSMSG());



%MEND OBSNVARS;&lt;/CODE&gt;&lt;/PRE&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;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Aug 2018 16:48:45 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-08-16T16:48:45Z</dc:date>
    <item>
      <title>Creating a dataset to capture all the observations of all tables in a program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-dataset-to-capture-all-the-observations-of-all-tables/m-p/487493#M127045</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think having not programmed anything new lately has really deteriorated my skills.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a really long program. I want to create a secondary QA dataset which captures all the table names, observations numbers, variable numbers as the program is running. This way in each step, I can compare observation numbers to ensure that they all match. This needs to be automated which is why I am asking for help here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I do this in a macro? I know how to set up macro variables to do this (see below). However, I cannot figure out how to do it in a dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO OBSNVARS(DS);
%GLOBAL DSET NVARS NOBS;
%LET DSET=&amp;amp;DS;

/* OPEN DATA SET PASSED AS THE MACRO PARAMETER */
%LET DSID = %SYSFUNC(OPEN(&amp;amp;DSET)); /*1 IF DATASET EXISTS; 0 IF DATASET DOES NOT EXIST*/

/* IF THE DATA SET EXISTS, GET THE NUMBER OF OBSERVATIONS */
/* AND VARIABLES AND THEN CLOSE THE DATA SET */
%IF &amp;amp;DSID %THEN
%DO;
%LET NOBS =%SYSFUNC(ATTRN(&amp;amp;DSID,NOBS));
%LET NVARS=%SYSFUNC(ATTRN(&amp;amp;DSID,NVARS));
%LET RC = %SYSFUNC(CLOSE(&amp;amp;DSID));
%END;

/* OTHERWISE, WRITE A MESSAGE THAT THE DATA SET COULD NOT BE OPENED */
%ELSE %PUT OPEN FOR DATA SET &amp;amp;DSET FAILED - %SYSFUNC(SYSMSG());



%MEND OBSNVARS;&lt;/CODE&gt;&lt;/PRE&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, 16 Aug 2018 16:14:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-dataset-to-capture-all-the-observations-of-all-tables/m-p/487493#M127045</guid>
      <dc:creator>lei</dc:creator>
      <dc:date>2018-08-16T16:14:17Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a dataset to capture all the observations of all tables in a program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-dataset-to-capture-all-the-observations-of-all-tables/m-p/487507#M127048</link>
      <description>&lt;P&gt;Would it be easier to hit SASHELP.VCOLUMN instead and retrieve that information?&lt;/P&gt;
&lt;P&gt;Would it also make sense to pass two data set names in so it can compare the record counts and let you know if there's an issue?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/7111"&gt;@lei&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think having not programmed anything new lately has really deteriorated my skills.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a really long program. I want to create a secondary QA dataset which captures all the table names, observations numbers, variable numbers as the program is running. This way in each step, I can compare observation numbers to ensure that they all match. This needs to be automated which is why I am asking for help here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I do this in a macro? I know how to set up macro variables to do this (see below). However, I cannot figure out how to do it in a dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO OBSNVARS(DS);
%GLOBAL DSET NVARS NOBS;
%LET DSET=&amp;amp;DS;

/* OPEN DATA SET PASSED AS THE MACRO PARAMETER */
%LET DSID = %SYSFUNC(OPEN(&amp;amp;DSET)); /*1 IF DATASET EXISTS; 0 IF DATASET DOES NOT EXIST*/

/* IF THE DATA SET EXISTS, GET THE NUMBER OF OBSERVATIONS */
/* AND VARIABLES AND THEN CLOSE THE DATA SET */
%IF &amp;amp;DSID %THEN
%DO;
%LET NOBS =%SYSFUNC(ATTRN(&amp;amp;DSID,NOBS));
%LET NVARS=%SYSFUNC(ATTRN(&amp;amp;DSID,NVARS));
%LET RC = %SYSFUNC(CLOSE(&amp;amp;DSID));
%END;

/* OTHERWISE, WRITE A MESSAGE THAT THE DATA SET COULD NOT BE OPENED */
%ELSE %PUT OPEN FOR DATA SET &amp;amp;DSET FAILED - %SYSFUNC(SYSMSG());



%MEND OBSNVARS;&lt;/CODE&gt;&lt;/PRE&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;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 16:48:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-dataset-to-capture-all-the-observations-of-all-tables/m-p/487507#M127048</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-16T16:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a dataset to capture all the observations of all tables in a program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-dataset-to-capture-all-the-observations-of-all-tables/m-p/487510#M127054</link>
      <description>&lt;P&gt;ABSOLUTELY. Thank you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 16:57:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-dataset-to-capture-all-the-observations-of-all-tables/m-p/487510#M127054</guid>
      <dc:creator>lei</dc:creator>
      <dc:date>2018-08-16T16:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a dataset to capture all the observations of all tables in a program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-dataset-to-capture-all-the-observations-of-all-tables/m-p/487511#M127055</link>
      <description>If you don't want specific variable information, just the number of rows/variables SASHELP.VTABLE is the one you want.</description>
      <pubDate>Thu, 16 Aug 2018 16:58:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-dataset-to-capture-all-the-observations-of-all-tables/m-p/487511#M127055</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-16T16:58:33Z</dc:date>
    </item>
  </channel>
</rss>

