Desktop productivity for business analysts and programmers

Create new variable from an existing variable

Reply
N/A
Posts: 0

Create new variable from an existing variable

I have a variable named A. I want to create a variable B wich is equal to LOG(A). How can I do this in SAS Enterprise Guide?
N/A
Posts: 0

Re: Create new variable from an existing variable

couple of ways come to mind

1) in a code segment
[pre]
data outdata;
set indata;
B = log(A); *--- this is a natural log (ln) by the way, not a base 10 log;
C = log10(A);
run;
quit;
[/pre]

2) as a computed value in a query
"drag" or place or double-click on the input dataset to add it to your project
right-click on the dataset
select Filter or Query ... from the popup menu
drag the variable A over to the selected tab panel/window/field_box
click on Computed Columns (above and slightly left of the list of variables in the input datasets)
click on New
Select Build Expression ...
enter into the top frame (Expression textSmiley Happy log10()
in between the parenthises, click to place the cursor, then from the right lower frame of the dialog box select variable A. Be sure you do it from the right side and not the left side.
Click Ok
Highlight "Calculated1"
Click Rename
Change the name to "B"
Click Close

The rest should be self-evident.
Ask a Question
Discussion stats
  • 1 reply
  • 1592 views
  • 0 likes
  • 1 in conversation