<?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: Conditionally executing a data step based upon last variable name or contents? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173578#M264481</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, this is possible to get last variable from the data set but if you are using the same data set for processing based on the extracted last variable then program will always process the first part because condition will&amp;nbsp; %if &amp;amp;countnum&amp;gt;0&amp;nbsp; %then %do will always be true.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 10 Jul 2014 21:33:25 GMT</pubDate>
    <dc:creator>stat_sas</dc:creator>
    <dc:date>2014-07-10T21:33:25Z</dc:date>
    <item>
      <title>Conditionally executing a data step based upon last variable name or contents?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173555#M264458</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How would I do this?&amp;nbsp; Using macros?&amp;nbsp; I want to automate and run code if the last column/variable's name and/or content fits a certain naming and/or content criteria.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jul 2014 15:20:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173555#M264458</guid>
      <dc:creator>zscott1</dc:creator>
      <dc:date>2014-07-09T15:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally executing a data step based upon last variable name or contents?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173556#M264459</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, macros or call execute, e.g.&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sasahelp.columns (where=(libname="YOURLIB" and memname="YOURDATASET"));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if name="YOURCOLUMN" then call execute('%do_somecodemacro();');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You would need to be more specific for a specific example.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jul 2014 15:24:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173556#M264459</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-07-09T15:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally executing a data step based upon last variable name or contents?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173557#M264460</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Specifically, let's say I want to automate sampling, proportional allocation stratify, if last variable name exists and/or contains something, SRS if it does not etc. automating as per the file loaded.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jul 2014 15:50:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173557#M264460</guid>
      <dc:creator>zscott1</dc:creator>
      <dc:date>2014-07-09T15:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally executing a data step based upon last variable name or contents?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173558#M264461</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That isn't enough information. For sampling, why not use proc surveyselect?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jul 2014 16:08:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173558#M264461</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-07-09T16:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally executing a data step based upon last variable name or contents?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173559#M264462</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can try this one which first checks &lt;STRONG&gt;lastvar&lt;/STRONG&gt; in the dataset &lt;STRONG&gt;have&lt;/STRONG&gt; and based on that split the process&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro check(dsname,var);&lt;BR /&gt;%let dsid=%sysfunc(open(&amp;amp;dsname));&lt;BR /&gt;%let countnum=%sysfunc(varnum(&amp;amp;dsid,&amp;amp;var));&lt;BR /&gt;%let rc=%sysfunc(close(&amp;amp;dsid));&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%if &amp;amp;countnum&amp;gt;0 and &amp;amp;var='Contains something' %then %do;&lt;/P&gt;&lt;P&gt;Stratified sampling&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%else %do;&lt;/P&gt;&lt;P&gt;SRS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend check;&lt;BR /&gt;%check(have,lastvar)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jul 2014 16:20:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173559#M264462</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-07-09T16:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally executing a data step based upon last variable name or contents?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173560#M264463</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In most cases when using CALL EXECUTE it is best to delay execution of the macro until after the data step finishes.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; call execute('&lt;STRONG&gt;%nrstr(&lt;/STRONG&gt;%do_somecodemacro();&lt;STRONG&gt;)&lt;/STRONG&gt;');&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jul 2014 17:13:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173560#M264463</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-07-09T17:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally executing a data step based upon last variable name or contents?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173561#M264464</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, I have to ask data_null_; how does the %nstr change the operation of call execute.&amp;nbsp; To my understanding call executes generates code which always executes after the containing step has finished irrespective of code used which is why it works particularly well as loop generation with a datastep.&amp;nbsp; E.g.&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.cars;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('aaaa');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When this gets sent to the compiler at each observation the text aaa would be put out to the compiler.&amp;nbsp; When the run; is encountered to end the datastep, the compiler then starts executing aaa then the next aaa etc. for however many were generated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jul 2014 17:57:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173561#M264464</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-07-09T17:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally executing a data step based upon last variable name or contents?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173562#M264465</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See &lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/64754/HTML/default/viewer.htm#n1q1527d51eivsn1ob5hnz0yd1hx.htm"&gt;Details.&amp;nbsp; &lt;/A&gt;It's all in the details as they say.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jul 2014 18:42:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173562#M264465</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-07-09T18:42:20Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally executing a data step based upon last variable name or contents?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173563#M264466</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks data _null_; I see what you mean now.&amp;nbsp; I don't really use macros so not really come across that.&amp;nbsp; Must try reading documentation sometime.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jul 2014 07:48:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173563#M264466</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-07-10T07:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally executing a data step based upon last variable name or contents?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173564#M264467</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am now attempting this code w/ a small dummy set but got&lt;/P&gt;&lt;P&gt;WARNING: Argument 2 to function VARNUM referenced by the %SYSFUNC or %QSYSFUNC macro function is out&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; of range.&lt;/P&gt;&lt;P&gt;NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; of the operations have been set to a missing value. errors&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table blue.fishdata as select fish_I, fins,&amp;nbsp; sea_depth&lt;/P&gt;&lt;P&gt;from blue.fishdata;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&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 dsname=blue.fishdata;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table &amp;amp;dsname as select *&lt;/P&gt;&lt;P&gt;from blue.fishdata;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro check(dsname,var);&lt;/P&gt;&lt;P&gt;%let dsid=%sysfunc(open(&amp;amp;dsname));&lt;/P&gt;&lt;P&gt;%let countnum=%sysfunc(varnum(&amp;amp;dsid,&amp;amp;var));&lt;/P&gt;&lt;P&gt;%let rc=%sysfunc(close(&amp;amp;dsid));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if &amp;amp;countnum&amp;gt;0 and &amp;amp;var format=4. %then %do;&lt;/P&gt;&lt;P&gt;proc contents;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%else %if &amp;amp;countnum format =2. %then %do;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select fish_I&lt;/P&gt;&lt;P&gt;from blue.fishdata;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend check;&lt;/P&gt;&lt;P&gt;%check(blue.fishdata,lastvar);&lt;/P&gt;&lt;P&gt;%check;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;my total log is as follows:&lt;/P&gt;&lt;P&gt;555&amp;nbsp; proc sql;&lt;/P&gt;&lt;P&gt;556&amp;nbsp; create table blue.fishdata as select fish_I, fins,&amp;nbsp; sea_depth&lt;/P&gt;&lt;P&gt;557&amp;nbsp; from blue.fishdata;&lt;/P&gt;&lt;P&gt;WARNING: This CREATE TABLE statement recursively references the target table. A consequence of this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; is a possible data integrity problem.&lt;/P&gt;&lt;P&gt;NOTE: Table BLUE.FISHDATA created, with 9 rows and 3 columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;558&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.02 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;559&lt;/P&gt;&lt;P&gt;560&lt;/P&gt;&lt;P&gt;561&lt;/P&gt;&lt;P&gt;562&amp;nbsp; %let dsname=blue.fishdata;&lt;/P&gt;&lt;P&gt;563&lt;/P&gt;&lt;P&gt;564&lt;/P&gt;&lt;P&gt;565&amp;nbsp; proc sql;&lt;/P&gt;&lt;P&gt;566&amp;nbsp; create table &amp;amp;dsname as select *&lt;/P&gt;&lt;P&gt;567&amp;nbsp; from blue.fishdata;&lt;/P&gt;&lt;P&gt;WARNING: This CREATE TABLE statement recursively references the target table. A consequence of this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; is a possible data integrity problem.&lt;/P&gt;&lt;P&gt;NOTE: Table BLUE.FISHDATA created, with 9 rows and 3 columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;568&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;569&lt;/P&gt;&lt;P&gt;570&amp;nbsp; %macro check(dsname,var);&lt;/P&gt;&lt;P&gt;571&amp;nbsp; %let dsid=%sysfunc(open(&amp;amp;dsname));&lt;/P&gt;&lt;P&gt;572&amp;nbsp; %let countnum=%sysfunc(varnum(&amp;amp;dsid,&amp;amp;var));&lt;/P&gt;&lt;P&gt;573&amp;nbsp; %let rc=%sysfunc(close(&amp;amp;dsid));&lt;/P&gt;&lt;P&gt;574&lt;/P&gt;&lt;P&gt;575&amp;nbsp; %if &amp;amp;countnum&amp;gt;0 and &amp;amp;var format=4. %then %do;&lt;/P&gt;&lt;P&gt;576&amp;nbsp; proc contents;&lt;/P&gt;&lt;P&gt;577&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;578&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;579&amp;nbsp; %else %if &amp;amp;countnum format =2. %then %do;&lt;/P&gt;&lt;P&gt;580&amp;nbsp; proc sql;&lt;/P&gt;&lt;P&gt;581&amp;nbsp; select fish_I&lt;/P&gt;&lt;P&gt;582&amp;nbsp; from blue.fishdata;&lt;/P&gt;&lt;P&gt;583&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;584&lt;/P&gt;&lt;P&gt;585&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;586&amp;nbsp; %mend check;&lt;/P&gt;&lt;P&gt;587&amp;nbsp; %check(blue.fishdata,lastvar);&lt;/P&gt;&lt;P&gt;588&amp;nbsp; %check;&lt;/P&gt;&lt;P&gt;WARNING: Argument 2 to function VARNUM referenced by the %SYSFUNC or %QSYSFUNC macro function is out&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; of range.&lt;/P&gt;&lt;P&gt;NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; of the operations have been set to a missing value.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jul 2014 16:42:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173564#M264467</guid>
      <dc:creator>zscott1</dc:creator>
      <dc:date>2014-07-10T16:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally executing a data step based upon last variable name or contents?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173565#M264468</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, glad you took my solution on-board :smileylaugh:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I think your problem is, is that you are creating a table - blue.fishdata - overwriting what is already there and only keeping three variables: fish_I, fins,&amp;nbsp; sea_depth&lt;/P&gt;&lt;P&gt;Then when you call the macro with: %check(blue.fishdata,lastvar);&amp;nbsp; there is no variable called lastvar in that dataset, hence you get an error.&amp;nbsp; If you are trying to find out how many variables there are in a dataset then query sashelp.vcolumn:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select count(*)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :num_vars&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sashelp.vcolumn&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where&amp;nbsp;&amp;nbsp; libname="SASHELP"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and memname="CARS";&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jul 2014 17:01:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173565#M264468</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-07-10T17:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally executing a data step based upon last variable name or contents?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173566#M264469</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What are you trying to do overall? I think your script is overkill and that using the SASHELP.VCOLUMN table to get all the metadata about variables is a better approach. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jul 2014 17:03:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173566#M264469</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-07-10T17:03:59Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally executing a data step based upon last variable name or contents?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173567#M264470</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Few things need to be done to make it work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table &lt;STRONG&gt;fishdata&lt;/STRONG&gt; as select fish_I, fins,&amp;nbsp; sea_depth /* Creating data in work lib */&lt;/P&gt;&lt;P&gt;from blue.fishdata;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro check(dsname,var);&lt;/P&gt;&lt;P&gt;%let dsid=%sysfunc(open(&amp;amp;dsname));&lt;/P&gt;&lt;P&gt;%let countnum=%sysfunc(varnum(&amp;amp;dsid,&amp;amp;var));&lt;/P&gt;&lt;P&gt;%let rc=%sysfunc(close(&amp;amp;dsid));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if &amp;amp;countnum&amp;gt;0 and &amp;amp;var &lt;STRONG&gt;format=4.&lt;/STRONG&gt; %then %do;&amp;nbsp;&amp;nbsp; /*Assign some value not format&amp;nbsp; like &lt;STRONG&gt;&amp;amp;var=4&lt;/STRONG&gt;*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc contents data=&lt;STRONG&gt;&amp;amp;dsname;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%else %do;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select fish_I&lt;/P&gt;&lt;P&gt;from &lt;STRONG&gt;&amp;amp;dsname;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend check;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%check(&lt;STRONG&gt;fishdata&lt;/STRONG&gt;,&lt;STRONG&gt;lastvar&lt;/STRONG&gt;); /* lastvar should be one of the variable in the dataset blue.fishdata,which are fish_I, fins,&amp;nbsp; sea_depth */&lt;/P&gt;&lt;P&gt;%check;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jul 2014 17:42:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173567#M264470</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-07-10T17:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally executing a data step based upon last variable name or contents?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173568#M264471</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;should it be "lastvar" or "last.var"?&amp;nbsp; I made the fixes both of you suggested but still get the error.... this is now my log&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1038&amp;nbsp; proc sql;&lt;/P&gt;&lt;P&gt;1039&amp;nbsp; create table fishdata as select fish_I, fins,&amp;nbsp; sea_depth&lt;/P&gt;&lt;P&gt;1040&amp;nbsp; from blue.fishdata;&lt;/P&gt;&lt;P&gt;NOTE: Table WORK.FISHDATA created, with 9 rows and 3 columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1041&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.26 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1042&lt;/P&gt;&lt;P&gt;1043&lt;/P&gt;&lt;P&gt;1044&lt;/P&gt;&lt;P&gt;1045&amp;nbsp; %let dsname=fishdata;&lt;/P&gt;&lt;P&gt;1046&amp;nbsp; %macro check(dsname,var);&lt;/P&gt;&lt;P&gt;1047&amp;nbsp; %let dsid=%sysfunc(open(&amp;amp;dsname));&lt;/P&gt;&lt;P&gt;1048&amp;nbsp; %let countnum=%sysfunc(varnum(&amp;amp;dsid,&amp;amp;var));&lt;/P&gt;&lt;P&gt;1049&amp;nbsp; %let rc=%sysfunc(close(&amp;amp;dsid));&lt;/P&gt;&lt;P&gt;1050&lt;/P&gt;&lt;P&gt;1051&amp;nbsp; %if &amp;amp;countnum&amp;gt;0&amp;nbsp; %then %do;&lt;/P&gt;&lt;P&gt;1052&amp;nbsp; proc contents data=&amp;amp;dsname;&lt;/P&gt;&lt;P&gt;1053&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;1054&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;1055&amp;nbsp; %else %if &amp;amp;countnum&amp;lt;0 %then %do;&lt;/P&gt;&lt;P&gt;1056&amp;nbsp; proc sql;&lt;/P&gt;&lt;P&gt;1057&amp;nbsp; select fish_I&lt;/P&gt;&lt;P&gt;1058&amp;nbsp; from &amp;amp;dsname;&lt;/P&gt;&lt;P&gt;1059&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;1060&lt;/P&gt;&lt;P&gt;1061&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;1062&amp;nbsp; %mend check;&lt;/P&gt;&lt;P&gt;1063&amp;nbsp; options mprint mlogic symbolgen;&lt;/P&gt;&lt;P&gt;1064&amp;nbsp; %check(&amp;amp;dsname,lastvar);&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK):&amp;nbsp; Beginning execution.&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable DSNAME resolves to fishdata&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK):&amp;nbsp; Parameter DSNAME has value fishdata&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK):&amp;nbsp; Parameter VAR has value lastvar&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK):&amp;nbsp; %LET (variable name is DSID)&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable DSNAME resolves to fishdata&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK):&amp;nbsp; %LET (variable name is COUNTNUM)&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable DSID resolves to 3&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable VAR resolves to lastvar&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK):&amp;nbsp; %LET (variable name is RC)&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable DSID resolves to 3&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable COUNTNUM resolves to 0&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK):&amp;nbsp; %IF condition &amp;amp;countnum&amp;gt;0 is FALSE&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable COUNTNUM resolves to 0&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK):&amp;nbsp; %IF condition &amp;amp;countnum&amp;lt;0 is FALSE&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK):&amp;nbsp; Ending execution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1065&amp;nbsp; proc sql;&lt;/P&gt;&lt;P&gt;1066&amp;nbsp; create table fishdata as select fish_I, fins,&amp;nbsp; sea_depth&lt;/P&gt;&lt;P&gt;1067&amp;nbsp; from blue.fishdata;&lt;/P&gt;&lt;P&gt;NOTE: Table WORK.FISHDATA created, with 9 rows and 3 columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1068&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1069&lt;/P&gt;&lt;P&gt;1070&lt;/P&gt;&lt;P&gt;1071&lt;/P&gt;&lt;P&gt;1072&amp;nbsp; %let dsname=fishdata;&lt;/P&gt;&lt;P&gt;1073&lt;/P&gt;&lt;P&gt;1074&lt;/P&gt;&lt;P&gt;1075&amp;nbsp; proc sql;&lt;/P&gt;&lt;P&gt;1076&amp;nbsp; create table &amp;amp;dsname as select *&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable DSNAME resolves to fishdata&lt;/P&gt;&lt;P&gt;1077&amp;nbsp; from blue.fishdatas;&lt;/P&gt;&lt;P&gt;NOTE: Table WORK.FISHDATA created, with 9 rows and 3 columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1078&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1079&lt;/P&gt;&lt;P&gt;1080&amp;nbsp; %macro check(dsname,var);&lt;/P&gt;&lt;P&gt;1081&amp;nbsp; %let dsid=%sysfunc(open(&amp;amp;dsname));&lt;/P&gt;&lt;P&gt;1082&amp;nbsp; %let countnum=%sysfunc(varnum(&amp;amp;dsid,&amp;amp;var));&lt;/P&gt;&lt;P&gt;1083&amp;nbsp; %let rc=%sysfunc(close(&amp;amp;dsid));&lt;/P&gt;&lt;P&gt;1084&lt;/P&gt;&lt;P&gt;1085&amp;nbsp; %if &amp;amp;countnum&amp;gt;0&amp;nbsp; %then %do;&lt;/P&gt;&lt;P&gt;1086&amp;nbsp; proc contents data=&amp;amp;dsname;&lt;/P&gt;&lt;P&gt;1087&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;1088&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;1089&amp;nbsp; %else %if &amp;amp;countnum&amp;lt;0 %then %do;&lt;/P&gt;&lt;P&gt;1090&amp;nbsp; proc sql;&lt;/P&gt;&lt;P&gt;1091&amp;nbsp; select fish_I&lt;/P&gt;&lt;P&gt;1092&amp;nbsp; from &amp;amp;dsname;&lt;/P&gt;&lt;P&gt;1093&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;1094&lt;/P&gt;&lt;P&gt;1095&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;1096&amp;nbsp; %mend check;&lt;/P&gt;&lt;P&gt;1097&amp;nbsp; options mprint mlogic symbolgen;&lt;/P&gt;&lt;P&gt;1098&amp;nbsp; %check(&amp;amp;dsname,last.var);&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK):&amp;nbsp; Beginning execution.&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable DSNAME resolves to fishdata&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK):&amp;nbsp; Parameter DSNAME has value fishdata&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK):&amp;nbsp; Parameter VAR has value last.var&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK):&amp;nbsp; %LET (variable name is DSID)&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable DSNAME resolves to fishdata&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK):&amp;nbsp; %LET (variable name is COUNTNUM)&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable DSID resolves to 3&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable VAR resolves to last.var&lt;/P&gt;&lt;P&gt;WARNING: Argument 2 to function VARNUM referenced by the %SYSFUNC or %QSYSFUNC macro function is out&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; of range.&lt;/P&gt;&lt;P&gt;NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; of the operations have been set to a missing value.&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK):&amp;nbsp; %LET (variable name is RC)&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable DSID resolves to 3&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable COUNTNUM resolves to .&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK):&amp;nbsp; %IF condition &amp;amp;countnum&amp;gt;0 is FALSE&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable COUNTNUM resolves to .&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK):&amp;nbsp; %IF condition &amp;amp;countnum&amp;lt;0 is TRUE&lt;/P&gt;&lt;P&gt;MPRINT(CHECK):&amp;nbsp;&amp;nbsp; proc sql;&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable DSNAME resolves to fishdata&lt;/P&gt;&lt;P&gt;MPRINT(CHECK):&amp;nbsp;&amp;nbsp; select fish_I from fishdata;&lt;/P&gt;&lt;P&gt;MPRINT(CHECK):&amp;nbsp;&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK):&amp;nbsp; Ending execution.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jul 2014 18:25:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173568#M264471</guid>
      <dc:creator>zscott1</dc:creator>
      <dc:date>2014-07-10T18:25:39Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally executing a data step based upon last variable name or contents?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173569#M264472</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;and for some reason it says I have 15 vars? which i don't i have 3 w/ true values and i got rid of blank column v4 by using the sql statement&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jul 2014 18:29:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173569#M264472</guid>
      <dc:creator>zscott1</dc:creator>
      <dc:date>2014-07-10T18:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally executing a data step based upon last variable name or contents?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173570#M264473</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Things ar getting more complicated. One quick question, which variable do you want to be checked for existance in fishdata?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jul 2014 18:37:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173570#M264473</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-07-10T18:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally executing a data step based upon last variable name or contents?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173571#M264474</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the last variable, which I originally intended to be sea_depth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jul 2014 18:54:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173571#M264474</guid>
      <dc:creator>zscott1</dc:creator>
      <dc:date>2014-07-10T18:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally executing a data step based upon last variable name or contents?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173572#M264475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this one hopefully should work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table fishdata as select fish_I, fins,&amp;nbsp; sea_depth&lt;/P&gt;&lt;P&gt;from blue.fishdata;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let dsname=fishdata;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options mprint mlogic symbolgen;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro check(dsname,var);&lt;/P&gt;&lt;P&gt;%let dsid=%sysfunc(open(&amp;amp;dsname));&lt;/P&gt;&lt;P&gt;%let countnum=%sysfunc(varnum(&amp;amp;dsid,&amp;amp;var));&lt;/P&gt;&lt;P&gt;%let rc=%sysfunc(close(&amp;amp;dsid));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if &amp;amp;countnum&amp;gt;0&amp;nbsp; %then %do;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc contents data=&amp;amp;dsname;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%else %do;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select fish_I&lt;/P&gt;&lt;P&gt;from &amp;amp;dsname;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend check;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%check(&amp;amp;dsname,sea_depth);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jul 2014 19:06:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173572#M264475</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-07-10T19:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally executing a data step based upon last variable name or contents?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173573#M264476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;great!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jul 2014 19:46:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173573#M264476</guid>
      <dc:creator>zscott1</dc:creator>
      <dc:date>2014-07-10T19:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally executing a data step based upon last variable name or contents?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173574#M264477</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually, there still is a problem... When I call the macro, I must call the variable name which is data specific, I want a macro that I can automate to call the last variable in the set, or the last variable sas can find which is populated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jul 2014 20:33:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-executing-a-data-step-based-upon-last-variable/m-p/173574#M264477</guid>
      <dc:creator>zscott1</dc:creator>
      <dc:date>2014-07-10T20:33:51Z</dc:date>
    </item>
  </channel>
</rss>

