Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Minitab Cookbook
  • Table Of Contents Toc
Minitab Cookbook

Minitab Cookbook

By : Isaac A Newton
4.4 (8)
close
close
Minitab Cookbook

Minitab Cookbook

4.4 (8)
By: Isaac A Newton

Overview of this book

Table of Contents (19 chapters)
close
close
Minitab Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1
Navigating Minitab and Useful Shortcuts
2
Index

Calculator – using an if statement


If statements can be useful tools in extracting information from a column or in reformatting data. Here, we will recode the values in the pulse worksheet.

In the pulse dataset, the C4 smokes column indicates if an individual is a smoker. 1 indicates a regular smoker and 2 stands for those who do not smoke. We will use an if statement to replace the numeric values for smokers and nonsmokers.

Getting ready

The data used here is one of the example files that come with Minitab. Open the pulse.mtw worksheet from the sample Minitab data folder by going to the File menu and clicking on Open Worksheet. Select the icon Look in Minitab Sample Data folder.

How to do it…

The following instructions will convert the values of 1 and 2 in the Smokes column to Smokes and Non-Smoker

  1. Go to the Calc menu and select Calculator.

  2. In Store result in variable, enter the column Smokes.

  3. In the Expression text box, enter IF('Smokes' = 1, "Smoker", "Non-Smoker").

  4. Click on OK.

How it works…

An if statement is entered in the following format: IF(Logical statement, TRUE, FALSE); the value entered after the first comma being the true for the statement. Numeric values for the response are entered purely as numbers without any double quotes. Text is always entered inside double quotes, for example, "True". Column names are used with single quotes, for example, 'Pulse1'.

Note

Column names can be typed, double-clicked, or selected in the column from the available list on the left of the dialog box. While single quotes are used to denote columns, they are not always necessary. A column name, that is, a single name without special characters or spaces in the name does not need to be referred to with single quotes. The column Ran can be used as Ran or 'Ran'. Selecting a column from the list will automatically enter single quotes where necessary.

There's more…

The IF statements can be generalized to multiple IF conditions very simply. A general IF statement would have the following syntax:

IF(Statement1, True1, Statement2, True2… StatementN, TrueN, False)

When identifying missing values in the worksheet, the code must be used as the first statement. These values can be identified with the code Miss() or '*'.

For example, the following will identify a missing result in the Smokes column as Unknown, 1 as Smoker, and all others as Non-Smoker:

IF('Smokes' = '*', "Unknown", 'Smokes' = 1, "Smoker", "Non-Smoker")

See also

  • The Calculator – basic functions recipe

  • The Coding a numeric column to text values recipe

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Minitab Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon