<?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: Count number of variables in dataset - for DDE in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Count-number-of-variables-in-dataset-for-DDE/m-p/86302#M24623</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ... one idea (use a separator that's not a character in your data ... I used a TAB) ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;question ...&amp;nbsp; what's that +1 for (index=nr+1) ... it's added in both examples below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data _null_;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;set sashelp.class nobs=obs;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;call symputx('obs',obs+1);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;call symputx('vars',countc(catx('09'x,of _all_),'09'x)+1);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;stop;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;or dictionary tables (separated by removes leading spaces in macro vars)...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;proc sql noprint;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;select nobs+1, nvar into :obs separated by ' ', :vars separated by ' '&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;from dictionary.tables&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;where libname eq 'SASHELP' and memname eq 'CLASS';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 18 Jun 2012 19:18:15 GMT</pubDate>
    <dc:creator>MikeZdeb</dc:creator>
    <dc:date>2012-06-18T19:18:15Z</dc:date>
    <item>
      <title>Count number of variables in dataset - for DDE</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Count-number-of-variables-in-dataset-for-DDE/m-p/86301#M24622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have used the following macro to count the number of rows and use it in my dde:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _NULL_;&lt;/P&gt;&lt;P&gt;if&amp;nbsp;&amp;nbsp; 0 then set TEST nobs=nr;&lt;/P&gt;&lt;P&gt;index=nr+1;&lt;/P&gt;&lt;P&gt;CALL SYMPUT(&lt;SPAN style="color: #ff0000;"&gt;'row2&lt;/SPAN&gt;', PUT(index, 5.));&lt;/P&gt;&lt;P&gt;stop;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;usage in DDE: FILENAME dataZ13 DDE "excel|[&amp;amp;template.]&amp;amp;section2.!r2c30:r&lt;SPAN style="color: #ff0000;"&gt;&amp;amp;row2.&lt;/SPAN&gt;c36" notab;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am wondering how I can do the same for the number of columns? I have a dataset where we add a new variable (column) every month. I was wondering if there was some similar macro that can count the number of columns so I do not have to keep changing the column limits in DDE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2012 18:14:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Count-number-of-variables-in-dataset-for-DDE/m-p/86301#M24622</guid>
      <dc:creator>vomer</dc:creator>
      <dc:date>2012-06-18T18:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of variables in dataset - for DDE</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Count-number-of-variables-in-dataset-for-DDE/m-p/86302#M24623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ... one idea (use a separator that's not a character in your data ... I used a TAB) ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;question ...&amp;nbsp; what's that +1 for (index=nr+1) ... it's added in both examples below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data _null_;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;set sashelp.class nobs=obs;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;call symputx('obs',obs+1);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;call symputx('vars',countc(catx('09'x,of _all_),'09'x)+1);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;stop;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;or dictionary tables (separated by removes leading spaces in macro vars)...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;proc sql noprint;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;select nobs+1, nvar into :obs separated by ' ', :vars separated by ' '&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;from dictionary.tables&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;where libname eq 'SASHELP' and memname eq 'CLASS';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2012 19:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Count-number-of-variables-in-dataset-for-DDE/m-p/86302#M24623</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2012-06-18T19:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of variables in dataset - for DDE</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Count-number-of-variables-in-dataset-for-DDE/m-p/86303#M24624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or compressing code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let dsid=%sysfunc(open(sashelp.class));&lt;/P&gt;&lt;P&gt;%let nvar=%sysfunc(attrn(&amp;amp;dsid,nvar));&lt;/P&gt;&lt;P&gt;%let dsid=%sysfunc(close(&amp;amp;dsid));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put &amp;amp;nvar ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jun 2012 02:54:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Count-number-of-variables-in-dataset-for-DDE/m-p/86303#M24624</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-06-19T02:54:21Z</dc:date>
    </item>
  </channel>
</rss>

