BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tasha
Calcite | Level 5

I am new to Enterprise Guide. I am using version 4.2.

I created a project and opened a dataset. Because this dataset is pointing to a another location, I am not able to directly add a new variable to it. I'm assuming this is correct.

So, I am using Query Builder where I add all the columns and would like to add some variables with conditions.

For example:

if column1='a' then order='First';

else if column1='b' then order='Second';

So, I am creating a new varaible order.

How can I add a new variable (if-then-else statement) to an open dataset in my project?

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
Doc_Duke
Rhodochrosite | Level 12

Tasha,

You can do this with the Query Builder task.  It does not modify the original data; rather it builds a new data set or view with the added column. 

Click computed column and then select recode.  The help should take you from there.

The SAS for Dummies (second edition) covers this and more for EGuide 4.2 and 4.3.

Doc Muhlbaier

Duke

View solution in original post

3 REPLIES 3
Doc_Duke
Rhodochrosite | Level 12

Tasha,

You can do this with the Query Builder task.  It does not modify the original data; rather it builds a new data set or view with the added column. 

Click computed column and then select recode.  The help should take you from there.

The SAS for Dummies (second edition) covers this and more for EGuide 4.2 and 4.3.

Doc Muhlbaier

Duke

Tasha
Calcite | Level 5

Thanks this helped greatly!

How can I use two variables from the dataset to create a new one? Is this possible?

Doc_Duke
Rhodochrosite | Level 12

It is possible, but can be more difficult.

If the result is to be numeric, you can do it as a 'formula" in the Advanced Expression part of the computed column.  To do that, you need to understand how columns are created in PROC SQL (because you are now writing a SQL expression).

You could also, potentially, do it as a two step process to create an intermediate variable.  This depends largely on what you want to do.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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
  • 3 replies
  • 1278 views
  • 0 likes
  • 2 in conversation