1

I'm importing data into SAS that is divided into columns by monetary value. The data in the columns is a count of how many people fit into that category.

Income_0-50K  Income_50-100K  Income_100K+
5             10              5

Once imported, I'd like to group the original data into only two columns to look like this:

Income_0_100K  Income_100K+
15             5

How do I do this using PROC SQL?

Alice Wang
  • 29
  • 4

1 Answers1

0

The term you want is creating a calculated field.

proc sql;
  select name, age, sex,
    (703*weight/(height**2)) as bmi
  from sashelp.class;
quit;

You select the calculation directly, so in my example the calculation is 703*weight/(height**2), and then you add as [name] where you replace [name] with your desired new column name.

If you don't want the original variables stored on the new dataset, just exclude them from the select as I did above. If you want to use select * but still want to exclude the variables, you can drop them:

proc sql;
  create table bmi(drop=height weight) as
  select *,
    (703*weight/(height**2)) as bmi
  from sashelp.class;
quit;
Joe
  • 62,789
  • 6
  • 49
  • 67