/* */

SASTechies

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

SAS Analytics Delivered to iPhone

 
  • Deliver SAS Reports and Data to Mobile Users
  • User Friendly Interface for Parameter Selection without Programming
  • Capture Real Time Data from SAS Directly from your iPhone
  • Intuitive Web Interface for Administrators and Power Users
  • Deliver Powerful Business Intelligence to iPhone®

 
Any SAS macros, programs or data can be delivered to iPhone. By simply registering the programs or SAS libraries, you can make this available to specified users who connect via standard 3G or Wifi network and results are delivered into a viewer on iPhone. This is executed in real time so the user gets always the latest data.

 

 


There are a number of ways to export data from SAS into Microsoft Excel. However, very few allow for exporting into custom-formatted spreadsheets such as those demanded for specific reports, in which explicit attributes such as font sizes and column widths are required. Traditionally, Dynamic Data Exchange (DDE) was the only way to do this. Now there are newer methods for this which are considered superior...

Various methods are ---

1. Proc Export / SAS Export wizard
2. Dynamic Data Exchange (DDE)
3. ODS CSV / HTML xls file route...create a .csv file and open with Excel
4. SAS to Excel via XML
5. Libname with xls
6. Using Display manager command Dexport to create a csv file

Export SAS datasets to Excel


1. Proc Export / SAS Export wizard




2. Dynamic Data Exchange (DDE)








Export SAS datasets to Excel with DDE -




3. ODS CSV / HTML xls file route...create a .csv file and open with Excel






4. SAS to Excel via XML


Export SAS datasets to Excel via XML -



5. Libname with xls


Export SAS datasets to Excel -

6. Using Display manager command Dexport to create a csv file....The Display manaager (DM Dexport) command invokes the External File Interface of SAS...

dm "dexport sashelp.class 'C:\class.csv' ";
dm "dexport sashelp.class 'C:\class.xls' ";

Interesting References....















TS-DOC TS-440 - How can I use PROC COMPARE to produce a report ... -

SAS Macros that Convert a Directory of Transport Files @ http://www.sas.com/govedu/fda/macro.html



Parallel processing SAS Batch jobs in Windows -


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)

SAS ODS Tips Sheets from SAS Institute

ODS

ODS DOCUMENT

ODS PDF

ODS RTF

ODS TAGSETS.RTF (SAS 9.2)

PROC TEMPLATE tables

PROC TEMPLATE styles

Reporting PROCs styles

Hash object

Perl regular expressions

SAS Slides 13 : Using Proc SQL


Introduction to Proc SQL


Introduction to Proc SQL -

Proc SQL: When and how to use it



PROC SQL When and How to Use It -


Top 10 Reasons to Learn Proc SQL

http://www2.sas.com/proceedings/sugi22/ADVTUTOR/PAPER35.PDF


Creating Macro variables with Proc SQL

http://www.cinsug.org/docs/frey/SELECTINTO.pdf


How can I get a new column like _N_ in my SAS table using PROC SQL



How can I get a new column like _N_ in my SAS table using PROC SQL ... -



Comparing SAS steps and PROC SQL_ Coding and Performance


Comparing SAS steps and PROC SQL_ Coding and Performance -

SAS Proc SQL example with Flow Diagram

www.pauldickman.com/teaching/sas/proc_sql_code_20041026.pdf

PROC SQL Why Use It When Simple IF THEN


PROC SQL Why Use It When Simple IF THEN -


SAS Learning Module Collapsing across observations using proc sql

SAS Learning Module Match merging data files using proc sql

Obtaining the Filename and Full Path of Submitted Programs

When you submit code or a catalog entry from the Enhanced Editor, the filename or catalog entry name and their respective folders are placed in these environment variables:

SAS_EXECFILEPATH

contains the full path of the submitted program or catalog entry. The full path includes the folder and the filename.

SAS_EXECFILENAME

contains only the name of the submitted program or the catalog entry name.

You can then extract the filename and full path for use in your SAS programs.

After the following DATA step runs and the data is sorted, the PRINT procedure includes the filename in the title and the full path in the footnote of the procedure output. The results are shown below as a Screen Shot

data oranges;

   input variety $ flavor texture looks;

   total=flavor+texture+looks;

cards;

navel 9 8 6

temple 7 7 7

valencias 8 9 9

mandarins 5 7 9

;

 

proc sort data=oranges;

   by descending total;

run;

 

proc print data=oranges;

title 'Taste Test Results for Oranges using File ' %sysget(SAS_EXECFILENAME);

footnote 'The full path is ' %sysget(SAS_EXECFILEPATH);

run;

The resulting output displays the filename in the title and the full path in the footnote:

Using an Environment Variable to Place a Filename in DATA Step Output

These environment variables are set only when code is submitted using the Enhanced Editor in the Windows environment. They are not set when you submit SCL code or when you submit code in a batch session.

However, when SAS is running in batch mode, you can obtain the full path (which includes the filename) by submitting %sysfunc(getoption(SYSIN)) . The following macro can be used to obtain the full path in both a batch session and an interactive session by using the Enhanced Editor:

%let execpath=" ";

%macro setexecpath;

   %let execpath=%sysfunc(GetOption(SYSIN));

   %if %length(&execpath)=0

      %then %let execpath=%sysget(SAS_EXECFILEPATH);

%mend setexecpath;

 

%setexecpath;

%put &execpath;

You can also use the following %PUT macro statements to display the filename and full path in the SAS log:

%put Submitted file path is %sysget(SAS_EXECFILEPATH).;

%put Submitted file name is %sysget(SAS_EXECFILENAME).;

 

Source: http://support.sas.com/onlinedoc/913/getDoc/en/hostwin.hlp/editor_enhanced.htm#eegetfilename

 




SAS Macro to delete a SAS dataset

Here’s a simple SAS Macro to delete a SAS dataset…It takes the name of the SAS dataset as the parameter...

%macro deletedsn(dsname);

%if %index(&dsname,.) eq 0  %then %do; %let lib=work; %let dsn=&dsname; %end;
%else %if %index(&dsname,.) gt 0  %then %do; %let lib=%scan(&dsname,1,.); %let dsn=%scan(&dsname,2,.); %end;

proc datasets lib=&lib nolist;
 delete &dsn;
quit;
%mend deletedsn;

%deletedsn(new);
%deletedsn(somelib.new);

A SAS Macro to Clean up the WORK directory…

Here is a macro to quickly cleanup the work directory programmatically…

It uses Proc Datasets with KILL option to delete the datasets in the library…


%macro CleanupWORK(membertype);

/***
ACCESS - access descriptor files (created by SAS/ACCESS software)
ALL - all member types
CATALOG- SAS catalogs
DATA - SAS data files
FDB - financial database
MDDB - multidimensional database
PROGRAM - stored compiled SAS programs
VIEW - SAS views
****/

%let validvals=ACCESS ALL CATALOG DATA FDB MDDB PROGRAM VIEW;
%if %index(&validvals,%upcase(&membertype)) gt 0 %then
  %do;
                        proc datasets lib=WORK kill nolist memtype=%upcase(&membertype);
                        quit;
   %end;
%mend;

%CleanupWORK(data);
 The valid values for the parameter memtype are ACCESS ALL CATALOG DATA FDB MDDB PROGRAM VIEW only…

SAS Code Examples




SAS STAT Examples

SAS Macros


SAS Annotated Output

SAS Library


What statistical analysis should I use?


SAS Textbook Examples
David Franklin's Examples


Common Programming Mistake with Proc Sort NODUPRECS -


The PRINTTO procedure defines destinations for SAS procedure output and for the SAS log. By default, SAS procedure output and the SAS log are routed to the default procedure output file and the default SAS log file for your method of operation. See Default Destinations for SAS Log and Procedure Output. You can store the SAS log or procedure output in an external file or in a SAS catalog entry. With additional programming, you can use SAS output as input data within the same job.
PROC PRINTTO <option(s)>;

To do this
Use this option
provide a description for a SAS log or procedure output stored in a SAS catalog entry
LABEL=
route the SAS log to a permanent external file or SAS catalog entry
LOG=
combine the SAS log and procedure output into a single file
LOG= and PRINT= with same destination
replace the file instead of appending to it
NEW
route procedure output to a permanent external file or SAS catalog entry or printer.
PRINT=

filename logf "C:\Documents and Settings\SASTechies\Desktop\log.txt";


proc printto log=logf new; /*redirecting the log to log.txt*/
   run;

  data numbers;
   input x y z;
   datalines;
 14.2   25.2   96.8
 10.8   51.6   96.8
  9.5   34.2  138.2
  8.8   27.6   83.2
 11.5   49.4  287.0
  6.3   42.0  170.7
;

proc printto print='C:\Documents and Settings\SASTechies\Desktop\output.txt' new; /*redirecting the output to output.txt*/
run;

proc print data=numbers;
   title 'Listing of NUMBERS Data Set';
run;

/* You can also combine the SAS log and procedure output into the same/single file.
   Note: that you should NOT have the NEW option in this case or else it would delete the contents of the files everytime there is a new line in the log/output
*/

filename combined "C:\Documents and Settings\SASTechies\Desktop\combined.txt";

proc printto print=combined; /*redirecting the output to combined.txt*/
run;

proc printto log=combined; /*redirecting the output to combined.txt*/
run;


proc print data=numbers;
   title 'Listing of NUMBERS Data Set';
run;

proc printto;run; /* Re-routing the log and output destinations to the default locations */







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