[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sas-l
Subject:    Re: To include the current date in filename of the dataset
From:       Andrew Karp <andrew () SIERRADATASCIENCE ! COM>
Date:       2012-12-21 20:49:51
Message-ID: 50D4CB6F.1030102 () sierradatascience ! com
[Download RAW message or body]

Hi Rebecca...

I am not sure if SYSFUNC will work under the circumstances in which you
are trying it.  But, one issue is that you coded DATA() not DATE().
There isn't a SAS function called "DATA()", which is why you received
the error message in your SASLOG.  Also, remember the rules for SAS data
set names.  They can't contain blanks and must be start with either a
letter or an underscore, and be composed solely of letters, numbers and
the underscore symbol.

Hope this helps...

Andrew

On 12/21/2012 12:29 PM, Yuan, Rebecca wrote:
> Hello all,
> 
> Thanks very much for your kind replies!
> 
> When I tried to use the system function %sysfunc, the log shows that
> 
> --------------------------------------
> ERROR: The DATA function referenced in the %SYSFUNC or %QSYSFUNC macro function is \
> not found. 313
> 314  data filename_%sysfunc(data(),yymmddn8.);
> 315  merge   a_file
> 316          b_file;
> 317  by  ch_number;
> 318  run;
> ---------------------------------------
> 
> Does that mean I cannot use it in the data process?
> 
> Thanks very much!
> 
> Cheers,
> 
> Rebecca
> 
> 
> 
> 
> -----Original Message-----
> From: Sierra Data Science/Andrew Karp [mailto:andrew@SIERRADATASCIENCE.COM]
> Sent: Friday, December 21, 2012 3:00 PM
> To: SAS-L@LISTSERV.UGA.EDU; Yuan, Rebecca
> Cc: Sierra Data Science/Andrew Karp
> Subject: Re: To include the current date in filename of the dataset
> 
> Here's another approach to the problem Rebecca posted.  In the DATA _NULL_ step \
> below I have created two macro variables.  The first stores the year, month and day \
> with a leading underscore and underscores separating the values.  The second \
> variable has the year month day, hour minute and second, with a leading underscore \
> and underscores separating each data value. References to the macro variables are \
> easily appended to a data set name in the DATA statement. 
> Hopefully the comments within the step explain more fully what I am trying to \
> accomplish.  If not, please post queries or send them to me directly. 
> Happy Holidays!
> Andrew Karp
> Sierra Data Science
> Sonoma, CA USA
> http://www.SierraDataScience.com
> 
> 
> data _null_;
> /* obtain today's date, assign to char var using YYMMDD10 informat, translate \
> default hypen separators to underscores to make string consistent with SAS data set \
> name requirements, precede string with a leading underscore, assign results to \
> macro variable RUN_DATE */ call \
> symputx('run_date',('_'||translate((put(today(),yymmdd10.)),'_','-'))); /* obtain \
> current hour, minute and second from system clock, assign returned values to char \
> vars with, if needed, leading zeros (e.g., if 9 am, value of hour is 09) */
> hour = put(hour(time()),z2.);
> minute = put(minute(time()),z2.);
> second = put(second(time()),z2.);
> /* add hour minute and second, computed above, separated by underscores, to the \
> current year, month and day as explained in first comment */
> call
> symputx('run_date_time',('_'||translate((put(today(),yymmdd10.)),'_','-')||'_'||hour||'_'||minute||'_'||second));
>  run;
> 
> options symbolgen;  * display resolved macro variables info in SASLOG;
> 
> * run on tiny made up data sets;
> 
> data file&run_date;
> do obs = 1 to 5;
> x  = 1000 * uniform(999);
> y  = 50 * uniform(999);
> output;
> end;
> run;
> 
> data file&run_date_time;
> do obs = 1 to 5;
> x  = 1000 * uniform(999);
> y  = 50 * uniform(999);
> output;
> end;
> run;
> 
> The SASLOG displays:
> 
> 203  options symbolgen;  * display resolved macro variables info in SASLOG;
> 204
> 205  * run on tiny made up data sets;
> 206
> SYMBOLGEN:  Macro variable RUN_DATE resolves to _2012_12_21
> 207  data file&run_date;
> 208  do obs = 1 to 5;
> 209    x  = 1000 * uniform(999);
> 210    y  = 50 * uniform(999);
> 211       output;
> 212          end;
> 213            run;
> 
> NOTE: The data set WORK.FILE_2012_12_21 has 5 observations and 3 variables.
> NOTE: DATA statement used (Total process time):
> real time           0.01 seconds
> cpu time            0.01 seconds
> 
> 
> SYMBOLGEN:  Macro variable RUN_DATE_TIME resolves to _2012_12_21_11_58_19
> 214
> 215  data file&run_date_time;
> 216  do obs = 1 to 5;
> 217    x  = 1000 * uniform(999);
> 218    y  = 50 * uniform(999);
> 219       output;
> 220          end;
> 221            run;
> 
> NOTE: The data set WORK.FILE_2012_12_21_11_58_19 has 5 observations and 3 \
>                 variables.
> NOTE: DATA statement used (Total process time):
> real time           0.01 seconds
> cpu time            0.01 seconds
> 
> ----------------------------------------------------------------------
> This message, and any attachments, is for the intended recipient(s) only, may \
> contain information that is privileged, confidential and/or proprietary and subject \
> to important terms and conditions available at \
> http://www.bankofamerica.com/emaildisclaimer.   If you are not the intended \
> recipient, please delete this message. 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic