BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MANIK1
Fluorite | Level 6

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

 
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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 solution in original post

15 REPLIES 15
MANIK1
Fluorite | Level 6

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

 
MANIK1
Fluorite | Level 6

What are you speaking??

I posted for answers.

Kurt_Bremser
Super User

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
Fluorite | Level 6
I dont have the software right now so asking your help.Please help me in solving 1 and 2 questions atleast.
MANIK1
Fluorite | Level 6
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.
Kurt_Bremser
Super User

@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.

Tom
Super User Tom
Super User

@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.

 

 

MANIK1
Fluorite | Level 6
Yes Sir.
I mean to say in that way.
Sorry i couldn't post in that way
My original post consists of only questions.
The thread which you replied were my answers for those questions .
Thank you for answering .Thank you so much.
I never used this interface and i was not aware and i don't have so much time at that moment to explore this site so couldn't upload it properly .
Will make sure that i will be uploading in a similar fashion of yours in future.
Thank you so much .
MANIK1
Fluorite | Level 6
And May i know the answer for Second question ?
Tom
Super User Tom
Super User

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.
MANIK1
Fluorite | Level 6
Thanks @Tom
andreas_lds
Jade | Level 19

Please stop shouting and add some explanation why you have difficulties answering the questions. All questions could be answered by reading the documentation.

Cynthia_sas
SAS Super FREQ
Hi:
You can use either SAS University Edition or SAS OnDemand for Academics to get access to SAS for free non-commercial learning purposes. This would allow you to test code and find out the answers on your own.

Cynthia

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 15 replies
  • 1452 views
  • 12 likes
  • 6 in conversation