Posts

Showing posts from June, 2009

%EVAL AND %SYSEVALF MACRO FUNCTIONS: GETTING TO KNOW THEM BETTER.

With the exception of %sysevalf function, integer arithmetic is the only way macro statements perform arithmetic calculations. Following are the few examples of macro statements performing integer arithmetic calculations: %let one= %eval (3+5); %let two= %eval (5*2); %let three= %eval (9/3); %let four= %eval (5/2); %put The value of one is &one; %put The value of two is &two; %put The value of three is &three; %put The value of four is & four; Open the Log file and see the results as follows: The value of one is 8 The value of two is 10 The value of three is 3 The value of four is 2 The value for macro variable four, should be 2.5, instead it shows only two. That happens because if we perform division on integers, integer arithmetic doesn’t take the fractional part into account. When we try to execute the integer arithmetic calculations of values with functional part, : %let last= %eval (5.0+3.0); /*INCORRECT*/ %EVAL function only supports integer arithmeti...

DEXPORT and DIMPORT: DISPLAY MANAGER commands used to IMPORT and EXPORT the Tab delimited (Excel and .CSV) files;

One of my favorite methods of exporting excel or .csv file is to use the ‘ DEXPORT ’ command-line command. This certainly reduces the amount of typing required to export the SAS dataset. Another interesting point is DEXPORT command works fine in UNIX and PC .   Syntax: dm “ DEXPORT libref.dsn 'filename.xls ' replace ;   "libref" is a library , "dsn" is the name of a SAS data set, and "filename.xls" is the name of the tab delimited text file(excel) being created. If we don’t specify the Libname or it is work then the dataset ‘dsn’ from the WORK directory is exported in a excel format to a specified location. Replace option … replaces the file if it already exists.     Use DIMPORT command-line command to convert/import a tab delimited (excel or .csv etc) into a SAS dataset. Syntax: dm “DIMPORT ‘filename.csv’ exc" replace; DIMPORT command tells SAS to import or convert the tab delimited file (filename.csv) to a SAS dataset named ‘ex...

IFC and IFN functions: New IF functions:

Objective: To Reduce the amount of typing required achieving an objective Syntax: IFN (condition, true, false, missing): ‘N’ stands for Numeric IFN returns a numeric value. It returns the true, false or missing value depending on whether the condition is true, false or missing. Syntax: IFC (condition, true, false, missing): ‘C’ stands for character IFC function has four parameters: 1) a logical expression 2) character value returned when true 3) value returned when false 4) value retuned when missing, which is optional. IFC (logical-expression, Character-value-returned-when-true, Character-value-returned-when-false, Character-value-returned-when-missing); IFC returns a character value. It returns the true, false or missing value depending on whether the condition is true, false or missing. Example: Assign a value to the VISIT variable (new) as per the VTYPE variable value. We can certainly achieve this task in diff. ways.. here are they... data old; input sitesub $ vtype vdate $; card...

How to Play BlackJack, Solitaire and Poker Games using the SAS software

Image
Here is how we can play BlackJack, Solitaire and Poker etc games using the SAS software. I bet most people Don't know about this........ Open the SAS session, GO TO Solutions > Accessories > Games and select any Game ... and enjoy.... I don't have any IDEA, Why SAS included Games in the Software.

Proc Lifetest: Survival Analysis Using SAS

Survival Analysis using SAS :Advanced PROC LIFETEST Survival Part 1 Survival Part 2

Concatenation FUNCTIONS & CALL ROUTINES:

CATS/CATT/CATX Call Routines CAT/CATS/CATT/CATX Functions These Functions and Call Routines can be used to join two or more strings together. Even though we can use the concatenation operator in combination with the STRIP, TRIM, or LEFT functions, these functions make it much easier to put strings together and if you wish, to place one or more separator characters between the strings. One advantage of using the call routines than the functions is improved performance. Note: *Call routine executes faster than the function… in specific… CALL CATS: To concatenate two or more strings, removing both leading and trailing blanks. CATS () stands for concatenate and strip. Just think the ‘S’ at the end of the CATS as “Strip Blanks”. Syntax: CALL CATS (result, string-1<, string-n>); Example: A=”ABC’; B=” CONSULTING”; C=”INC “; D=” TEAM “; FUNCTION= RESULT CALL CATS(RESULT, A,B)= "ABCCONSULTING" CALL CATS(RESULT, A,B,C)= "ABCCONSULTINGINC" CALL CA...

Self Teach SAS tutorials

Image
SAS Tutorials The following are a series of self-teach tutorials which will introduce you to the command language approach to SAS programming. Each tutorial is designed to take about twenty minutes. To work through the tutorials you need to be on a machine which has SAS Version 8 loaded on it, or has access to SAS through the campus network. The material presented in the tutorials is designed to get you 'up and running.' Consequently, many options are omitted. Check the SAS help files for more a detailed discussion of the procedures outlined in the tutorials. The last tutorial is an introduction to SAS Analyst which is SAS's version of a 'point and click' approach to statistical analysis. Starting SAS under Windows Tutorial 1: Data Steps Part 1 Tutorial 2: Data Steps Part 2 Tutorial 3: Data Transformation and Selection Tutorial 4: Displaying the Data Tutorial 5: Some Basic Statistical Procedures SAS Analyst tutorial--interactive SAS SAS Multilevel Interactive d ire...

Clean-Up: Delete datasets in the work library:

It is better always to clean-up/empty the work directory before we run the next set of SAS code. This is VERY helpful in situations where the “working” files created tend to use up a large amount of memory, once the logic of the program has been checked, KILLing the working files will result in a more efficient program. Another important reason to issue the above statement at the end of a program is when programs are run in batch, this will clean up the working library to be sure any “old” files are not left around to be erroneously used1. PROC DATASETS procedure offers an elegant solution to do just. Remember that there is no need of knowing any dataset names when we are emptying the work directory. Here is the simple syntax: proc datasets lib=work kill nolist memtype=data; quit; We have specified lib=work, because we are cleaning up the work directory. KILL option removes all the datasets that are happened to be in the work directory. NOLIST option tells SAS, printing the details...