Creating new variables

Senast ändrad: 03 oktober 2019

Creating new variables is easily done in a data step. We could use

The new variable is created in a data step, i.e. we make a new data set.

data indata3;
set indata2;
(data manipulations);
run;

Explanation:

We created a new data set indata3 and use the old data set indata2 (if you have created this, otherwise your dataset). In (data manipulation) list the rows that create the new variable. Here are some examples:

data indata3;
set indata2;
logconcent=log(concent);

*a log-transform of the concent variable;

if concent =>13 then output; 
* the observation is kept in the data set only if the value of concent is larger or equal to 13;

if concent < 13 then delete;
*the same as above;

if type='B' then concent=concent+5;
*if the variable type is equal to B the value of concent is increased by 5;

month=month(date);
*creates a variable that contains the number of the month out of the existing date variable
run;

 


Kontaktinformation