<?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: how to write a macro variable into existing dataset? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582740#M165810</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272354"&gt;@Ivan555&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Concerning this topic - maybe one macro variable and one dataset could be enough to mark my problem&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;(without sashelp tables and %macro)&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No macros are needed. The data is there for your use in SASHELP.VTABLE&lt;/P&gt;</description>
    <pubDate>Wed, 21 Aug 2019 12:03:18 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-08-21T12:03:18Z</dc:date>
    <item>
      <title>how to write a macro variable into existing dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582135#M165517</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've done a code, question inside:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data t_names;
&amp;nbsp; &amp;nbsp; &amp;nbsp;length table_name $256 table_cnt 8;
&amp;nbsp; &amp;nbsp; &amp;nbsp;input table_name;
&amp;nbsp; &amp;nbsp; &amp;nbsp;table_num +1;
&amp;nbsp; &amp;nbsp; &amp;nbsp;datalines;
AIR
AIRLINE
BIRD
;
run;

proc sql noprint; select count(*) into dataset_cnt from t_names; quit;
%macro aaa;
&amp;nbsp; &amp;nbsp; &amp;nbsp;%do i=1 %to &amp;amp;dataset_cnt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;proc sql noprint; select table_name into: tmp1 from t_names where table_num = &amp;amp;i; quit;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;proc sql noprint; select count(*) into: tmp2 from sashelp.&amp;amp;tmp1; quit;&lt;BR /&gt;&lt;STRONG&gt;/*probably here I want to put tmp2 variable in the dataset "t_names" in the column "table_cnt" where "table_num"=&amp;amp;i&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;how is it possible to write? */&lt;/STRONG&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;%end;
mend aaa;
&lt;BR /&gt;%aaa;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;THX!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 15:40:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582135#M165517</guid>
      <dc:creator>Ivan555</dc:creator>
      <dc:date>2019-08-19T15:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to write a macro variable into existing dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582141#M165519</link>
      <description>&lt;P&gt;It would really help if you explained what this program is trying to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems as if you are trying to count the number of observations in each of the three tables, AIR AIRLINE and BIRD. Is that it? And then you want to add this number of observations to the appropriate row of T_NAMES, yielding (I made up the numbers)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;AIR         28
AIRLINE     97
BIRD        12&lt;/PRE&gt;
&lt;P&gt;If that's what you are trying to do, don't bother. All of this information is in the dictionary tables, at SASHELP.VTABLE. You don't have to compute it and then add it to a table, it's already in the dictionary table, which is really just a data view that you can use for any purpose.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 17:01:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582141#M165519</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-19T17:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to write a macro variable into existing dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582315#M165608</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you, you are right, the final goal is to make a dictionary table for each library.&lt;/P&gt;&lt;P&gt;SASHELP is a well-done library, it has dictionary tables.. other libraries I have dont have dictionaries.&lt;/P&gt;&lt;P&gt;&amp;gt; 1/ so on the first step I want to calculate the number of observation and to put it in the dictionary table&lt;/P&gt;&lt;P&gt;&amp;gt; 2/ on the next step I will try to calculate the size 10 observations of each table and to put them&amp;nbsp;in the dictinary table&lt;/P&gt;&lt;P&gt;&amp;gt; 3/ on the next step having 10obsSize and TotalObsCount I will try to calculate approximate full size of the table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2 and 3 steps are not the case of this topic, I will think and I hope after I'll be able to do them myself.. but I can't catch how I could technically put data, being contained in macro variable to existing dataset&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 07:20:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582315#M165608</guid>
      <dc:creator>Ivan555</dc:creator>
      <dc:date>2019-08-20T07:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: how to write a macro variable into existing dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582320#M165611</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272354"&gt;@Ivan555&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;EM&gt;other libraries I have dont have dictionaries&lt;/EM&gt;"&lt;/P&gt;
&lt;P&gt;SAS adds all tables of all libraries that you've got assigned in a SAS session to the SAS dictionary tables. These SAS dictionary tables are also accessible via views under library SASHELP.&lt;/P&gt;
&lt;P&gt;ALL SAS tables will have the number of rows as an attribute stored in the dictionary tables. Tables from libraries that point to databases will have a missing value for the row count because that's not a table attribute of database tables (like it is for SAS tables).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you clearly specify what you want to achieve then I'm sure people here will be able to give you a lot of guidance.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 06:57:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582320#M165611</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-08-20T06:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to write a macro variable into existing dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582343#M165623</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;SAS adds all tables of all libraries that you've got assigned in a SAS session to the SAS dictionary tables. These SAS dictionary tables are also accessible via views under library SASHELP.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Thank you, I see, that is very convenient.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Tables from libraries that point to databases will have a missing value for the row count&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Unfortunately that is my case.&lt;/P&gt;&lt;P&gt;So I have to calculate some parameters myself..&lt;/P&gt;&lt;DIV class="lia-quilt-row lia-quilt-row-forum-message-main"&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-20 lia-quilt-column-right lia-quilt-column-main-right"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-right"&gt;&lt;DIV class="lia-message-body lia-component-body"&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;If you clearly specify what you want to achieve then I'm sure people here will be able to give you a lot of guidance.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Speaking in terms of&amp;nbsp;SASHELP.VTABLE&amp;nbsp;I want to have filled with values columns&lt;BR /&gt;1. "nobs"&lt;BR /&gt;2. "filezise" (approximately, tables are very big)&lt;BR /&gt;for libraries that point to databases - that is my final goal.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I dont know, will it be fair if I'll ask you to do whole task for me?&lt;/P&gt;&lt;P&gt;The subject in topic is&amp;nbsp;narrower..&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 20 Aug 2019 09:17:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582343#M165623</guid>
      <dc:creator>Ivan555</dc:creator>
      <dc:date>2019-08-20T09:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: how to write a macro variable into existing dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582368#M165637</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;other libraries I have dont have dictionaries.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, they do have dictionary tables, it's the same table I mentioned SASHELP..VTABLE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So there's no need for any macro code to do any of your steps.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 10:44:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582368#M165637</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-20T10:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to write a macro variable into existing dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582370#M165639</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272354"&gt;@Ivan555&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;DIV class="lia-quilt-row lia-quilt-row-forum-message-main"&gt;
&lt;DIV class="lia-quilt-column lia-quilt-column-20 lia-quilt-column-right lia-quilt-column-main-right"&gt;
&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-right"&gt;
&lt;DIV class="lia-message-body lia-component-body"&gt;
&lt;DIV class="lia-message-body-content"&gt;
&lt;P&gt;will it be fair if I'll ask you to do whole task for me?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, in my opinion, that's not a fair question. You need to try to do it yourself, and if you get stuck, show us your code/log and we can help you from there.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 10:46:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582370#M165639</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-20T10:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to write a macro variable into existing dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582376#M165645</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272354"&gt;@Ivan555&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;sashelp.vtable is a view that points to one of the actual SAS dictionary tables. You can either query the view or the dictionary table directly. You can also figure out where the actual dictionary table "lives" by looking into the view definition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  describe view sashelp.vtable;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;28         proc sql;
29           describe view sashelp.vtable;
NOTE: SQL view SASHELP.VTABLE is defined as:

        select *
          from DICTIONARY.TABLES;

30         quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To then get the full definition of this table you can execute&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  describe table dictionary.tables;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SAS dictionary tables are READ ONLY. But you can of course create your own table by joining the dictionary table with additional information you're deriving yourself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You're after a row count and the file size for database tables. This is information you need to retrieve by querying the database directly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know what filesize means in the context of a database so you have to work this out for yourself. Below sample code demonstrating how you could get the row counts. Row counts are in the data bases I work mostly with not a table attribute and for this reason not available as dictionary information. It requires a SQL select count(*) against every single table so that's going to be a costly process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;SPAN&gt;&lt;EM&gt;will it be fair if I'll ask you to do whole task for me?&lt;/EM&gt;"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Not really, no. That's what many of us are doing as a paid job so it's not for free. But well, I got inspired so below should already give you quite a lot.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below code sample executes against SAS library WORK but it should work for any library pointing to a database. You will have to amend the code to fit your needs but it's likely already 80% of the solution for you.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options ls=max ps=max;

/* create some tables in library work */
data work.class work.class2;
  set sashelp.class;
  output work.class;
  if _n_&amp;lt;5 then output work.class2;
run;

/* create list of tables in Work */
proc sql;
  create table tableList as
  select l.engine, t.*
  from 
    (select distinct libname, engine from dictionary.libnames where libname='WORK') l 
    inner join 
    dictionary.tables t 
      on l.libname=t.libname and t.memtype='DATA' 
  order by libname, memname
  ;
quit;

/* execute select count(*) against all tables in WORK */
%macro countRows(outtbl, libname, memname, engine);
  %if %upcase(&amp;amp;memname) ne _THISCOUNT %then
    %do;
      %if &amp;amp;engine = V9 %then
        %do;
          /* do not execute a select count(*) against Base SAS tables */
          data _thisCount;
            length libname $8 memname $32 nlobs 8;
            stop;
          run;
        %end;
      %else
      %do;
        proc sql;
          create table _thisCount as
          select 
            "&amp;amp;libname" as libname length=8,
            "&amp;amp;memname" as memname length=32,
            count(*) as nlobs length=8
          from &amp;amp;libname..&amp;amp;memname
          ;
        quit;
      %end;
      proc append data=_thisCount base=&amp;amp;outtbl;
      run;
      proc datasets lib=work nolist nowarn;
        delete _thisCount;
        run;
      quit;
    %end;
%mend;

proc datasets lib=work nolist nowarn;
  delete _rowCounts;
  run;
quit;

data _null_;
  set tableList;
  call execute(cats('%countRows(_rowCounts,', libname, ',', memname, ',', engine, ')'));
run;

/* create new table by joining SAS dictionary table with result table from select count(*) */
data want;
  if _n_=1 then
    do;
      dcl hash h1(dataset:'_rowCounts');
      h1.defineKey('libname','memname');
      h1.defineData('nlobs');
      h1.defineDone();
    end;
  set tableList;
  if h1.find()=0 then nobs=nlobs;
run;

proc print data= want;
/*  var libname memname nobs nlobs;*/
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please try to understand above code before asking for more.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 11:33:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582376#M165645</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-08-20T11:33:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to write a macro variable into existing dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582694#M165794</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;Yes, they do have dictionary tables, it's the same table I mentioned SASHELP..VTABLE.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;Understood, I see them, thank you.&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;So there's no need for any macro code to do any of your steps.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Unfortunatelly I don't have &lt;SPAN&gt;columns&amp;nbsp;"nobs"&amp;nbsp;and "filesize" filled with values, so I think I have&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;to calculate them manually.&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;No, in my opinion, that's not a fair question. You need to try to do it yourself, and if you get stuck, show us your code/log and we can help you from there.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;I completely agree. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Next time I will try to make my head question shorter.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Concerning this topic - maybe one macro variable and one dataset could be enough to mark my problem&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;(without sashelp tables and %macro)&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am very thankful for you for your concern.&lt;/P&gt;&lt;P&gt;I will very attentivly study it today and mabe tomorrow and give you reply.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 08:13:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582694#M165794</guid>
      <dc:creator>Ivan555</dc:creator>
      <dc:date>2019-08-21T08:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to write a macro variable into existing dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582740#M165810</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272354"&gt;@Ivan555&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Concerning this topic - maybe one macro variable and one dataset could be enough to mark my problem&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;(without sashelp tables and %macro)&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No macros are needed. The data is there for your use in SASHELP.VTABLE&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 12:03:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582740#M165810</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-21T12:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: how to write a macro variable into existing dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582756#M165817</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;P&gt;No macros are needed. The data is there for your use in SASHELP.VTABLE&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Sorry, but it seems you don't listen to me..&lt;/P&gt;&lt;P&gt;This table is useful, thank you for the link, but it doesn't have the data, which I need.&lt;/P&gt;&lt;P&gt;Values in columns&amp;nbsp;"nobs"&amp;nbsp;and "filesize" are missing - emptiness&amp;nbsp;inside.&lt;/P&gt;&lt;P&gt;The only library which has tables(rows in &lt;SPAN&gt;SASHELP.VTABLE)&lt;/SPAN&gt;, being filled with "obs" and "filesize" values is SASHELP&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 13:11:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582756#M165817</guid>
      <dc:creator>Ivan555</dc:creator>
      <dc:date>2019-08-21T13:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: how to write a macro variable into existing dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582762#M165820</link>
      <description>&lt;P&gt;You don't want to write a "macro variable" into the dataset. You want to store the record count into a variable in the dataset.&amp;nbsp; In general you don't want to move data into macro variables (which are text) and then back into data.&amp;nbsp; You can lose precision of the numbers and it just makes things more complicated.&lt;/P&gt;
&lt;P&gt;Also before you try creating a macro program make sure you know what code you want to create.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t_names;
  table_num +1;
  length table_name $256 table_cnt 8;
  input table_name;
datalines;
CLASS
CARS
;

proc sql;
update t_names
  set table_cnt = (select count(*) from sashelp.class)
  where table_name='CLASS'
;
quit;

proc print data=t_names;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Once you know what code you want to generate you can then work on generating the code.&amp;nbsp; It might be easier to generate this code from the original dataset instead of making a macro program.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename code temp;
data _null_;
  set t_names;
  where missing(table_cnt);
  file code ;
  put 'update t_names set table_cnt = (select count(*) from sashelp.' table_name
       ')  where table_name=' table_name $quote. ';'
  ;
run;
proc sql;
 %include code / source2;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Aug 2019 13:20:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582762#M165820</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-08-21T13:20:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to write a macro variable into existing dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582796#M165837</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272354"&gt;@Ivan555&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;No macros are needed. The data is there for your use in SASHELP.VTABLE&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sorry, but it seems you don't listen to me..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;My apologies, it seems you are correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Fortunately,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;seems to have paid attention and found the answer.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 14:02:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/582796#M165837</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-21T14:02:20Z</dc:date>
    </item>
    <item>
      <title>Re: how to write a macro variable into existing dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/584484#M166496</link>
      <description>&lt;P&gt;I am back &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;I bring apologies to everyone, I was terribly busy last week.&lt;/P&gt;&lt;P&gt;I really appreciate any help, please do not try to see disrespect in my disappearance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you, understood, that is exactly what I was trying to do.&lt;/P&gt;&lt;P&gt;The idea with writing code instead of macro is very smart, I haven't seen this ever before &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thats is very fine that we understood each other. Thank you for your advices.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your feedback.&lt;/P&gt;&lt;P&gt;In general, I understood your code and in the first approximation I don't have any questions about it.&lt;/P&gt;&lt;P&gt;I think on the next step I will try to combine your approach, Tom's approach and some my thoughts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my opinion, Tom's code is more consistent with the originally stated topic, it might be better to choose it as a solution.&lt;/P&gt;&lt;P&gt;Please tell me, if I create another topic like&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Calculation of approximate Library size (which points to databases - tables have missing values of the sizes and rows counts)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;, could you copy your post into it?&lt;BR /&gt;(this could be done to save important information - so that other members of the SAS Community could more easily find and maybe use it if there will be a need.)&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2019 09:52:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/584484#M166496</guid>
      <dc:creator>Ivan555</dc:creator>
      <dc:date>2019-08-28T09:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to write a macro variable into existing dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/584485#M166497</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272354"&gt;@Ivan555&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have a new question related to what has been discussed here then just start a new discussion and copy/paste a reference to the related discussion. Also mark the answer which helped you the most in the old discussion as solution so the discussion gets "closed".&lt;/P&gt;
&lt;P&gt;As for what contributions you're in the end using: That's really fully up to you. I'm not taking any offence if that's not what I've posted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just as a comment to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;'s code: If you have to care about performance then don't issue a select count(*) against SAS tables as there the row count is a table attribute (nlobs) which you can retrieve directly from the descriptor (metadata) part of the table. That's much faster than a select count(*) which processes the data.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2019 10:07:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/584485#M166497</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-08-28T10:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to write a macro variable into existing dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/584526#M166507</link>
      <description>&lt;P&gt;You can query metadata from some systems to get record counts, but that does not work for all.&amp;nbsp; For example for VIEWs.&lt;/P&gt;
&lt;P&gt;That is why the code I posted included this statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  where missing(table_cnt);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Aug 2019 12:21:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/584526#M166507</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-08-28T12:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to write a macro variable into existing dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/585142#M166817</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;About:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;If you have to care about performance then don't issue a select count(*) against SAS tables as there the row count is a table attribute (nlobs) which you can retrieve directly from the descriptor (metadata) part of the table.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have missing values in all descritor parts..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Previosly you wrote:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Tables from libraries that point to databases will have a missing value for the row count because that's not a table attribute of database tables (like it is for SAS tables).&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I think that is my case, so I have to calculate metadata for several libraries consisting of ~500 tables manually.. but this will be another topic I think.&lt;/P&gt;&lt;P&gt;I think&amp;nbsp;during September I will write a code being based on your and Tom's solution.&lt;/P&gt;&lt;P&gt;I also think I will post it for information and will make a link on this discussion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One more time:&amp;nbsp; Big THX for Everyone, I am closing the topic.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 08:48:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-a-macro-variable-into-existing-dataset/m-p/585142#M166817</guid>
      <dc:creator>Ivan555</dc:creator>
      <dc:date>2019-08-30T08:48:23Z</dc:date>
    </item>
  </channel>
</rss>

