1. Will the following SAS code results in an output dataset or a results viewer?
Proc means data=cashvolatility noprint;
var cash;
by year;
output out=means mean=avgcash std=stdcash;
run;
No to output dataset, yes to results viewer
No to both
Yes to output dataset , no to results viewer
Yes to both
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
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
Reference the following SAS code:
Data Cash; Set Leverage;
Run;
4. Was a new dataset created by this line? If so what is the dataset name?
No
Yes, Leverage
Yes, Cash
Yes, Data
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
1. Will the following SAS code results in an output dataset or a results viewer?
Proc means data=cashvolatility noprint;
var cash;
by year;
output out=means mean=avgcash std=stdcash;
run;
No to output dataset, yes to results viewer
No to both
Yes to output dataset , no to results viewer
Yes to both
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
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
Reference the following SAS code:
Data Cash; Set Leverage;
Run;
4. Was a new dataset created by this line? If so what is the dataset name?
No
Yes, Leverage
Yes, Cash
Yes, Data
What are you speaking??
I posted for answers.
Read the relevant documentation, and the answers will be VERY easy. If in doubt, simply test the code.
If you're not willing to invest a little effort yourself, you'll never become any good with SAS.
@MANIK1 wrote:
Atlease say whether my answers are correct or wrong
Yes,to both
Unknown because we do not know how many companies are in the initial dataset.
Ensures that the mean of cash is measured as the average of cash
Yes the dataset will be created with name Cash.
Third and fourth answer are OK.
For the first and second, review the proc means documentation. @Astounding has given you hints to crucial parts.
I recommend to study what the by statement does in proc means, and how the variable used in it determines the size of the output.
@MANIK1 wrote:
Atlease say whether my answers are correct or wrong
Yes,to both
Unknown because we do not know how many companies are in the initial dataset.
Ensures that the mean of cash is measured as the average of cash
Yes the dataset will be created with name Cash.
Your original post did not provide your answers. Just the questions.
Are the last four lines of this particular post intended as your answers? If so then you should have labeled them with at least the question numbers to make it easier to check and also to make it clearer what this post was trying to say.
Something like this:
1. Will the following SAS code results in an output dataset or a results viewer?
Proc means data=cashvolatility noprint;
var cash;
by year;
output out=means mean=avgcash std=stdcash;
run;
No to output dataset, yes to results viewer
No to both
--> Yes to output dataset , no to results viewer
Yes to both
That seems to be the best answer since the NOPRINT option was included on the PROC statement which suppress the output that PROC MEANS normally produces. But perhaps by "results viewer" they mean the automatic opening of generated datasets that Enterprise Guide and SAS/Studio will do when configured that way. In which case the last answer might be better as the dataset will both be generated and it will be opened in a viewer. They didn't give an option of neither, which is what will happen if the input dataset does not exist or it is not sorted by YEAR.
If you can provide your answers in a similar way then we can provide feedback on your level of understanding. Be sure to include any specific questions about things that seem confusing to you to help direct the comments.
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
Please stop shouting and add some explanation why you have difficulties answering the questions. All questions could be answered by reading the documentation.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.