/* */

SASTechies

Place to learn SAS and enhance your professional career...

This article has been moved to different location. Please click on below link to go to new location.


http://technico.qnownow.com/sas-analytics-delivered-to-iphone/

This article has been moved to different location. Please click on below link to go to new location.


http://technico.qnownow.com/export-data-from-sas-into-microsoft-excel/

This article has been moved to different location. Please click on below link to go to new location.


http://technico.qnownow.com/sas-enterprise-guide-4-1-tutorial/

This article has been moved to different location. Please click on below link to go to new location.


http://technico.qnownow.com/using-proc-compare-to-validate-compare-data/

This article has been moved to different location. Please click on below link to go to new location.


http://technico.qnownow.com/common-sas-programming-mistakes/

This article has been moved to different location. Please click on below link to go to new location.


http://technico.qnownow.com/sas-macros-that-convert-a-directory-of-transport-files/

This article has been moved to different location. Please click on below link to go to new location.


http://technico.qnownow.com/parallel-processing-sas-batch-jobs-in-windows-os/

This article has been moved to different location. Please click on below link to go to new location.


http://technico.qnownow.com/running-sas-in-batch-mode-in-windows-os/

This sample shows a macro version and the data step version that can be used to find the nth business day of a given month and year.

This example uses the INTNX function to increment the date, time, or datetime value by a given interval or intervals.
http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a000212700.htm

This macro is a modified version of the Source: http://support.sas.com/kb/37/632.html


/* This code creates the macro variable DAY that is the nth day of the month. The macro variable is in the SAS date format
*/

%macro test1(checkday,month,year);
%global day;
%let date=%str(%'01)%upcase(%substr(&month,1,3))&year%str(%'d);
%put date=&date;


%let nthday=0; 

%let n=0;   
%do %until(&nthday=&checkday); 
/* create a variable whose value is the first day of the month*/  
%let begin_month=%sysfunc(intnx(month,&date,0,B)); 
/* increment the date by 1 day at a time*/  
%let day=%sysfunc(intnx(day,&begin_month,&n)); 
/* determine the day of the week*/  
%let weekday=%sysfunc(weekday(&day));
/* if the day of the week is not Saturday or Sunday then increment 
nthday plus 1*/ 
%if &weekday ne 7 and &weekday ne 1 %then %let nthday=%eval(&nthday+1);
%let n=%eval(&n+1);
%end;
/* checks the DAY macro variable by writing it to the log in the DATE9.
format*/
%put %sysfunc(putn(&day,date9.));
%mend
 
%test1(5,SEP,2010)   
 

%macro test2(checkday,month,year););
  %global day;
data test;  
  date=input(compress('01'||substr("&month",1,3)||&year),date9.);

  put date=;
  nthday=0;
  n=0
  do until(nthday=&checkday);
  begin_month=intnx('month',date,0,'B'); 
  day=intnx('day',begin_month,n);
  weekday=weekday(day);
  if weekday ne 7 and weekday ne 1 then nthday=nthday+1
  n+1
  end; 
  drop begin_month weekday date n; 
run; 
 
proc print;
  format day date9.
run; 

%mend

%test2(8,april,2010)

This article has been moved to different location. Please click on below link to go to new location.


http://technico.qnownow.com/sas-ods-tips-sheets-from-sas-institute/

This article has been moved to different location. Please click on below link to go to new location.


http://technico.qnownow.com/all-about-proc-sql/

This article has been moved to different location. Please click on below link to go to new location.


http://technico.qnownow.com/obtaining-the-filename-and-full-path-of-submitted-programs/

This article has been moved to different location. Please click on below link to go to new location.


http://technico.qnownow.com/sas-macro-to-delete-a-sas-dataset/

This article has been moved to different location. Please click on below link to go to new location.


http://technico.qnownow.com/a-sas-macro-to-clean-up-the-work-directory/

This article has been moved to different location. Please click on below link to go to new location.


http://technico.qnownow.com/sample-sas-codes-on-the-internet/

This article has been moved to different location. Please click on below link to go to new location.


http://technico.qnownow.com/common-programming-mistake-with-proc-sort-noduprecs/

This article has been moved to different location. Please click on below link to go to new location.


http://technico.qnownow.com/redirecting-your-sas-log-and-output-to-external-files/





Technology Top Blogs Programming Blogs - BlogCatalog Blog Directory TopOfBlogs Blog Directory blogarama - the blog directory blog search directory Blog Directory - OnToplist.com hihera.com On our way to 1,000,000 rss feeds - millionrss.com Increase Page Rank