<?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 Passing a variable as an argument to a function ??? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Passing-a-variable-as-an-argument-to-a-function/m-p/125757#M34581</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an issue, maybe small but something that has bugged me through experimentation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a data set which contains a variable which contains a list of date variables concatenated (I originally got all date variables using the vcolumns options for each data set and stored them in a variable) :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;E.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Dataset&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Dates&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;X1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;DT1, DT2, DT3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;X2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;DT1, DT3, DT4, DT5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;X3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;DT1, DT2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;X4&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;DT1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then want to have a min function to find the minimum of all the date fields in the dataset:, using dataset X1 as an example;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data testX1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set X1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; mindt = min(dates);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now this falls over as states it doesn't contain enough arguments. I can see the issue in that "dates" is only a single variable. How can I modify this to read the contents of the variables as the argument e.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dates testX1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set X1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; mindt = min(DT1,DT2,DT3);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works, but as I have to do this dynamically for a number of datsets, I tried storing the values as a variable and read this variable in, any suggestion please?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume a do loop, or create a macro variable but unsure as to how this works as to passing in a function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 02 Mar 2013 12:00:29 GMT</pubDate>
    <dc:creator>wjugon85</dc:creator>
    <dc:date>2013-03-02T12:00:29Z</dc:date>
    <item>
      <title>Passing a variable as an argument to a function ???</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Passing-a-variable-as-an-argument-to-a-function/m-p/125757#M34581</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an issue, maybe small but something that has bugged me through experimentation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a data set which contains a variable which contains a list of date variables concatenated (I originally got all date variables using the vcolumns options for each data set and stored them in a variable) :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;E.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Dataset&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Dates&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;X1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;DT1, DT2, DT3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;X2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;DT1, DT3, DT4, DT5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;X3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;DT1, DT2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;X4&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;DT1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then want to have a min function to find the minimum of all the date fields in the dataset:, using dataset X1 as an example;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data testX1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set X1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; mindt = min(dates);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now this falls over as states it doesn't contain enough arguments. I can see the issue in that "dates" is only a single variable. How can I modify this to read the contents of the variables as the argument e.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dates testX1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set X1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; mindt = min(DT1,DT2,DT3);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works, but as I have to do this dynamically for a number of datsets, I tried storing the values as a variable and read this variable in, any suggestion please?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume a do loop, or create a macro variable but unsure as to how this works as to passing in a function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Mar 2013 12:00:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Passing-a-variable-as-an-argument-to-a-function/m-p/125757#M34581</guid>
      <dc:creator>wjugon85</dc:creator>
      <dc:date>2013-03-02T12:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a variable as an argument to a function ???</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Passing-a-variable-as-an-argument-to-a-function/m-p/125758#M34582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How are you using the information?&amp;nbsp; Looks to me like you have a table with metadata that you want to use to generate code.&amp;nbsp; So when you generate the code put out the value of the variable instead of its name.&amp;nbsp; To get the MIN() function to not complain about too few arguments add in addition missing values as arguments.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data metadata;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;input ds $ dates $30. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;cards;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;X1 DT1, DT2, DT3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;X2 DT1, DT3, DT4, DT5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;X3 DT1, DT2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;X4 DT1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;;;;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;filename code temp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data _null_ ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; file code ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set metadata ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; put 'data test' ds ';'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; / '&amp;nbsp; set ' ds ';'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; / '&amp;nbsp; mindt = min(.,.,' dates ');'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; / 'run;'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;*** GENERATED PROGRAM **** ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data testX1 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set X1 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; mindt = min(.,.,DT1, DT2, DT3 );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data testX2 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set X2 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; mindt = min(.,.,DT1, DT3, DT4, DT5 );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data testX3 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set X3 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; mindt = min(.,.,DT1, DT2 );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data testX4 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set X4 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; mindt = min(.,.,DT1 );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Mar 2013 15:06:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Passing-a-variable-as-an-argument-to-a-function/m-p/125758#M34582</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-03-02T15:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a variable as an argument to a function ???</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Passing-a-variable-as-an-argument-to-a-function/m-p/125759#M34583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this does indeed generate code, here is the issue I have in that I am using this call within a call execute statement. When I run this, it tells me the variable ' date ', is not numeric, again true as this contains just a meta list of the variables. Here I have attached my program:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;** ASSIGN A CUT DATE **;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let cutdt= "19FEB2013"d ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;** GET A LIST OF ALL DATASETS IN LIBRARY **;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data dsnames(keep=memname);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set sashelp.vtable;&lt;/P&gt;&lt;P&gt;&amp;nbsp; where libname = 'RAWSDTM';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;** GET A LIST OF ALL DATE9. VARIABLES FROM THE DATASETS IN LIBRARY **;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data dscols(keep=memname name);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set sashelp.vcolumn;&lt;/P&gt;&lt;P&gt;&amp;nbsp; where libname = 'RAWSDTM' and format='DATE9.';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;** TRANSPOSE SO THAT 1 ROW PER DATASET CONTAINING COLUMNS WITH VARIABLE NAMES **;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=dscols out=dscolst(drop = _NAME_ _LABEL_);&lt;/P&gt;&lt;P&gt;&amp;nbsp; var name;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by memname;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;** MERGE DATES ON TO DATASET AND CONCATENATE EACH DATE VARIBALE INTO A SINGLE DATE VARIABLE TO BE USED IN CALCULATIONS **;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data all(keep=memname date);&lt;/P&gt;&lt;P&gt;&amp;nbsp; options missing='';&lt;/P&gt;&lt;P&gt;&amp;nbsp; merge dsnames dscolst;&lt;/P&gt;&lt;P&gt;&amp;nbsp; attrib date length=$300.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by memname;&lt;/P&gt;&lt;P&gt;&amp;nbsp; date=catx(',', of col:);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;** MACRO TO BE USED IN CALL EXECUTE TO CUT DATA BY PASSING IN DATASET FROM META DATASET ABOVE **;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro cut(dsname);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; data &amp;amp;dsname._dates(keep=memname date);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set all;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where memname="&amp;amp;dsname";&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table &amp;amp;dsname as select&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a.*, b.date from&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RAWSDTM.&amp;amp;dsname a left join &amp;amp;dsname._dates b&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on a.form=b.memname;&lt;/P&gt;&lt;P&gt;&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; data ANA.&amp;amp;dsname ANA.&amp;amp;dsname._cut;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set &amp;amp;dsname;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; attrib mindt format=date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mindt = min(.,.,'date');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if datepart(mindt) &amp;lt;= &amp;amp;cutdt then output ANA.&amp;amp;dsname;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else output ANA.&amp;amp;dsname._cut;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend cut;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;** EXECUTE THE MACRO VIA CALL EXECUTE **;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set all;&lt;/P&gt;&lt;P&gt;&amp;nbsp; call execute ('%cut('||memname||')');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All works fine if remove the min statement that I am having issues with...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Mar 2013 16:13:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Passing-a-variable-as-an-argument-to-a-function/m-p/125759#M34583</guid>
      <dc:creator>wjugon85</dc:creator>
      <dc:date>2013-03-02T16:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a variable as an argument to a function ???</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Passing-a-variable-as-an-argument-to-a-function/m-p/125760#M34584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So what you want to do in your macro is pull the VALUE of the date variable into a macro variable.&amp;nbsp; Then replace 'date' with reference to that macro variable.&amp;nbsp; You could probably simplify your whole process if instead of even building the concatenated variable list you just left them as rows in a table.&amp;nbsp; Then the key parts of your code would look something like below.&amp;nbsp; (NOTE: I have used space as the delimiter and the OF keyword in the MIN() function call instead of dealing with commas. )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%local varlist ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;select name into :varlist separated by ' ' from ....&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;mindt = min(.,of &amp;amp;varlist);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;....&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Mar 2013 16:33:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Passing-a-variable-as-an-argument-to-a-function/m-p/125760#M34584</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-03-02T16:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a variable as an argument to a function ???</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Passing-a-variable-as-an-argument-to-a-function/m-p/125761#M34585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is a much more compact way.&amp;nbsp; I made the CUT macro accept the list of date variables (and other things) as inputs. Plus it is easier to build your list of dataset names and the associated list of date variables using a single data step. You also might want to search for other formats than just DATE (such as MMDDYY, DDMMYY, YYMMDD) depending on how much control you have over the source datasets.&lt;/P&gt;&lt;P&gt;Note that DATEPART() function is something you apply to DateTime variables.&amp;nbsp; If you apply it to a Date variable you will get wrong result.&amp;nbsp; If you want to find DateTime variables then perhaps you could generate DATEPART(dtvar) into your DATES string.&amp;nbsp; Example: dates= 'DOB VISITDT datapart(EVENTTS)'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%macro cut(dsname,cutdt,varlist=,inlib=,outlib=) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;* Split dataset based on cutoff date ;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data &amp;amp;outlib..&amp;amp;dsname &amp;amp;outlib..&amp;amp;dsname._cut;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set &amp;amp;libref..&amp;amp;dsname;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; attrib mindt format=date9. label='Minimum value of all date variables';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; mindt = min(of . &amp;amp;varlist);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if mindt &amp;lt;= &amp;amp;cutdt then output &amp;amp;outlib..&amp;amp;dsname;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; else output &amp;amp;outlib..&amp;amp;dsname._cut;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%mend cut;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let cutdt= "19FEB2013"d ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let libref = RAWSDTM ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;*----------------------------------------------------------------------;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;* Get list of DATE variables ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;* Call CUT macro for each dataset ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;*----------------------------------------------------------------------;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data datevars(keep=memname dates);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; length memname $32 dates $300 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; do until (last.memname);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.vcolumn;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by memname ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where libname = %upcase("&amp;amp;libref")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and format =: 'DATE'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dates=catx(' ',dates,name);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; call execute (cats(&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; '%cut(dsname=',memname&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; ,",cutdt=&amp;amp;cutdt"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; ,',varlist=',dates&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; ,",inlib=&amp;amp;libref"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; ,',outlib=ANA'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; ,')'))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Mar 2013 17:21:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Passing-a-variable-as-an-argument-to-a-function/m-p/125761#M34585</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-03-02T17:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a variable as an argument to a function ???</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Passing-a-variable-as-an-argument-to-a-function/m-p/125762#M34586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi TOm,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the above, looks good and agree is more efficient, I do seem to have a problem calling the cutoff date within the call execute statement, I cannot seem to fathom why?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: Line generated by the macro variable "CUTDT".&lt;/P&gt;&lt;P&gt;106&amp;nbsp; ",cutdt="19FEB2013" d&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -----------&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 49&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 388&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 200&lt;/P&gt;&lt;P&gt;NOTE 49-169: The meaning of an identifier after a quoted string may change in a future SAS release.&amp;nbsp; Inserting white space between a quoted string and the succeeding&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; identifier is recommended.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 388-185: Expecting an arithmetic operator.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I keep getting this error when running the above as it is. Any suggestion, UI have tried playing around but to no avail.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2013 00:27:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Passing-a-variable-as-an-argument-to-a-function/m-p/125762#M34586</guid>
      <dc:creator>wjugon85</dc:creator>
      <dc:date>2013-03-04T00:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a variable as an argument to a function ???</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Passing-a-variable-as-an-argument-to-a-function/m-p/125763#M34587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is just an issue with using the same quoting character outside and inside.&lt;/P&gt;&lt;P&gt;You could change the code in the CALL EXECUTE to use single quotes or change the value used in defining CUTDT macro variable to use single quotes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2013 03:54:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Passing-a-variable-as-an-argument-to-a-function/m-p/125763#M34587</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-03-04T03:54:18Z</dc:date>
    </item>
  </channel>
</rss>

