BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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?
1 REPLY 1
deleted_user
Not applicable
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 text:) 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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 5800 views
  • 0 likes
  • 1 in conversation