Computing new column using base sas

In Base SAS, you can create a new column in a data set using various methods. Here are a few examples:

Method 1: Using the SET statement

You can use the SET statement to create a new column by assigning a value to a new variable. For example:

data mydata;
  set mydata;
  new_column = old_column + 1;
run;

This code creates a new column called new_column by adding 1 to the existing old_column.

Method 2: Using the FORMAT statement

You can use the FORMAT statement to create a new column by formatting an existing column. For example:

data mydata;
  set mydata;
  format new_column $10.;
  new_column = put(old_column, $10.);
run;

This code creates a new column called new_column by formatting the existing old_column as a character variable with a length of 10.

Method 3: Using the INFORMAT statement

You can use the INFORMAT statement to create a new column by reading an existing column using a specific format. For example:

data mydata;
  set mydata;
  informat new_column mmddyy10.;
  new_column = input(old_column, mmddyy10.);
run;

This code creates a new column called new_column by reading the existing old_column as a date variable in the format mmddyy.

Method 4: Using the ARRAY statement

You can use the ARRAY statement to create a new column by processing an array of values. For example:

data mydata;
  set mydata;
  array old_cols old_column1-old_column5;
  do i = 1 to dim(old_cols);
    new_column = sum(old_cols(i));
  end;
run;

This code creates a new column called new_column by summing up the values in the old_column1 to old_column5 array.

These are just a few examples of how you can create a new column in Base SAS. The specific method you use will depend on the requirements of your analysis and the structure of your data.