The %EVAL function evaluates integer arithmetic or logical expressions. %EVAL operates by converting its argument from a character value to a numeric or logical expression. Then, it performs the evaluation. Finally, %EVAL converts the result back to a character value and returns that value.
Operands that contain a period character cause an error when they are part of an integer arithmetic expression. The following examples show correct and incorrect usage, respectively:
Often we need to add a prefix to some or all variables in a dataset before we might have to merge datasets that have similar column attributes…This macro would allow you to do that….
SAS Macros that Convert a Directory of Transport Files @ http://www.sas.com/govedu/fda/macro.html
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:
contains the full path of the submitted program or catalog entry. The full path includes the folder and the filename.
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
Here’s a simple SAS Macro to delete a SAS dataset…It takes the name of the SAS dataset as the parameter…
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… The valid values for the parameter memtype are ACCESS ALL CATALOG DATA FDB MDDB PROGRAM VIEW only…
SAS has a macro that creates a delimited text file from a SAS dataset @ SAS Macro to Create a delimited text file from a SAS data set..
Often a times, we get a dataset with missing values for certain variables…And for reporting purposes we need to convert them some or all of those variable values to default values (for e.g 0 for numeric values or NULL for character values)..
Well…there are many ways of getting the observation count into a macro variable…but there a few pros and cons in those methods…
How do you reorder variables in a dataset…I get this many a times….Here’s a macro for you to achieve it…For example I’ve used a dataset sashelp.flags and created some more variables with variety of variables with names upper / lower cases and _’s to demonstrate the reorder macro….