Randomly select character values for each observation
In the example dataset – SASHELP.HEART, you want to create a new variable – Activity_status and assign one of three values of (‘High’, ‘MEDIUM’, ‘LOW’), at random to each observation. You can achieve these using 2 methods. Method 1: Using an array data heart(drop=id _1-_3 keep=status sex bp_status chol_status activity_status); set sashelp.heart(obs=10); array _{3} $… (0 comment)

Removing dashes and parentheses from phone numbers
Removing dashes and parentheses from phone numbers is one of the common data cleaning activities. This program uses the compress function to remove unwanted characters from a phone number. data phone_number; input Phone $ 1-20; Phone_number=compress(Phone, , 'kd'); datalines; (908)235-4490 (201) 555-77 99 ; title 'Removing dashes and parentheses from phone numbers'; proc print data=phone_number;… (0 comment)

SAS data sets consist of a descriptor portion and a data portion that contains the data values. The descriptor portion of a SAS data set holds the detailed information about the data set. This information includes: Dataset name and its ember type Creation time of the dataset The number of observations The number of variables The… (0 comment)

Sorting Orders for Numeric Variables Numeric variables are sorted from the smallest-to-largest comparison and the sequence is as below. SAS System missing values (shown as a period or special missing value) negative numeric values zero positive numeric values. Sorting Orders for Character Variables PROC SORT uses either the EBCDIC or the ASCII collating sequence when… (0 comment)

There are a number of statements, options, functions, and programming alternatives that are well suited to controlling how and when all or a portion of a program can be stopped conditionally. Sometimes we want to control the flow of the individual data steps of the program. This may include the termination of a step or even the SAS job itself. There are several exit strategies depending on the objective.… (0 comment)