Practice Final Flashcards

1
Q

F33

The data set “houses” contains observations of home sales data. It shows the date of sale
(“saledate”), the amount the house was sold for (“saleprice”), and the number of days it was
on the market (“numdays”). Write SAS code that does the following:
a) Finds the median sales value.
b) Merges that median value back onto the “houses” data set.
c) Print out all homes with a sales price within $20,000 of the median price.
d) Calculates the correlation between days on the market (numdays) and the sale price.

A

HOUSES - saledate saleprice numdays
Part a
proc means data = houses noprint;
var saleprice;
output out = medianprice median(saleprice) = medsprice;
run;

Part b
data houses;
set houses;
key = 1;
run;
data medprice;
set medprice;
key = 1;
run;
data combo;
merge houses medprice;
by key;
run;

**part c **
data houses2;
set houses;
diff = saleprice - medsprice;
if -20000 le diff le 20000;
run;
proc print data = houses2;
run;

part d
proc corr data = houses; *two by two
var numday saleprice;
run;

part d: using var & with would only calculate one correlation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

F33 Proc sql approach

A

PROC SQL;
[create table as]
select *, median(salesprice) as medsprice from houses;
quit;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

F34
The data set named “numbers” has 21 variables: country and then 20 columns of annual
GDP data from 1996 to 2015. For example, a single observation from this data set would
look like:
Country GDP1996 GDP1997 GDP1998 …. GDP2015
Brazil 458.7 499.2 513.4 … 468.9
Chile 653.1 781.6 883.9 … 697.2
Denmark 310.0 391.5 402.7 … 457.4
a) Identify the year for each country with the highest and lowest GDP between 1996 and
2015. Then, identify (across all countries) the most frequent year (e.g., 1999) that
countries had the highest GDP as well as the most frequent year that countries had their
lowest GDP.
b) Write a program to transform this data set into another data set that has just three
columns: Country, year, and GDP.

A

part a
data numbers;
set numbers;
array gdp[20] gdp1996 – gdp2015;
maxgdp = max(of GDP:);
mingdp = min(of GDP:);
do i = 1 to 20;
if GDP[i] = maxgdp
then maxyear = 1995 + i;
if GDP[i] = mingdp
then minyear = 1995 +i;
run;
proc freq data = numbers;
tables minyear maxyear;
run;

part b
proc transpose data = numbers;
by country; what we dont want to move/transpose
var year GDP;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

F25

  1. If the following code is submitted and then followed by a PROC PRINT, what will be the
    resulting title in the output?
    %LET title = The Amazing Race;
    TITLE ‘&title’;
A

&title

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

F26

What is a parameter in a macro and why would you want to use one?

A

A parameter is a macro variable and to make your code less repetitive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly