Ok. Let's look at the last three.
2. If this sample includes company information for years 2001 to 2010, how many observations would be included in an output dataset (if one exists)? Use the following SAS code:
Proc means data=cashvolatility noprint;
var cash;
by year;
output out=means mean=avgcash std=stdcash;
run;
100
--> 10 <--
Unknown because we do not know how many companies are in the initial dataset
1
10 is the best answer, but that requires making a lot of assumptions. First that the variable YEAR is coded with values like 2001, 2002, to 2010 and not in some other way. For example if it was coded as a DATE variable with YEAR format attached to it the values would look like there were only 10 values, but perhaps different records used different days from within that year. The BY statement will ignore the format attached and just use the distinct actual values. Also that all 10 years actual have records in the dataset. And that the dataset is actually sorted by the YEAR variable (in ascending order).
3. What does mean=avgcash do in the following SAS code?
Proc means data=cashvolatility noprint;
var cash;
by year;
output out=means mean=avgcash std=stdcash;
run;
Requires only the output to include the mean of cash
Takes the average of cash holdings
--> Renames the variable representing mean of cash to avgcash <--
Ensures that the mean of cash is measured as the average of cash
The MEAN= option on the OUTPUT statement of PROC MEANS (and SUMMARY) gives in instructions to both INCLUDE the MEAN statistic in the output dataset and how to NAME the variable. It is not really RE-naming the variable since a variable with the MEAN of CASH didn't exist until PROC MEANS calculated it.
4. Reference the following SAS code:
Data Cash; Set Leverage;
Run;
Was a new dataset created by this line? If so what is the dataset name?
No
Yes, Leverage
--> Yes, Cash <--
Yes, Data
The name(s) listed on the DATA statement are the names of the dataset being created. Even if CASH existed before it will be replaced by the result of this data step, so it will definitely be a NEW dataset.
Note that the use the word LINE in the question is inappropriate. SAS does not care about line breaks when interpreting code. And anyway the code posted is two lines in the question. This data step has three STATEMENTS.
... View more