DATA Step, Macro, Functions and more

Questions regarding very Basic SAS programming

Not applicable
Posts: 1

Questions regarding very Basic SAS programming

I am enrolled in a SAS course at college and recently we got some problems to do. I do not have the book yet and cannot seem to find information on how to solve the following questions from it. If someone can point me in the right direction until my book comes or show me where i can access beginner SAS info until my book arrives that would be great.

. An experiment was run to study battery life and the data was recorded as shown below. Place the data in the current format after the Datalines; statement in your SAS code:

A Radio 8.6

A Camera 8.2

A DVD 7.9

A Radio 8.4

A Camera 5.4

A DVD 5.7

B Radio 9.4

B Camera 8.8

B DVD 8.5

B Radio 8.9

B Camera 5.8

B DVD 5.9

C Radio 8.5

C Camera 8.6

C DVD 7.8

C Radio 7.6

C Camera 5.1

C DVD 5.4

D Radio 9.1

D Camera 8.8

D DVD 8.9

D Radio 8.7

D Camera 5.8

D DVD 5.6

Write an appropriate Data step to read in the data and using only the “Proc Print” statement function (no formatting statements allowed) to output the data in the following layout shown below:

Battery Radio Camera DVD

A 8.6 8.2 7.9

A 8.4 5.4 5.7

B 9.4 8.8 8.5

B 8.9 5.8 5.9

C 8.5 8.6 7.8

C 7.6 5.1 5.4

D 9.1 8.8 8.9

D 8.7 5.8 5.6

Note that the first row the desired layout consists of variable labels.


Import the file diamond.xls into SAS and complete the following tasks:
1. Create a new variable which for the price per carat. Print the 401st to 500th observation in the data set.
2. Print the price by clarity for only colors D and I.
3. Print the price per carat (as produced in Part a) by color, for clarity VS1.
4. Print this data set for only diamonds having clarity ranking of IF.
5. Based on the above, explain how ratings for clarity and color impact the price. What is the best way of printing out the data to explain the impact of color and clarity on price? Explain.

The problem with the above is i cannot seem to change or add variables after i import the .dat file. I know most of the rest.

Super Contributor
Super Contributor
Posts: 3,176

Re: Questions regarding very Basic SAS programming

The SAS support website has much to offer you in SAS-hosted documentation and supplemental technical / reference material.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search arguments, this topic / post:

intro data step programming

data step documentation


Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation