BookmarkSubscribeRSS Feed
nhev
Fluorite | Level 6
1)How to calculate average using proc summary by cars and road? Then use the summary to calculate the average of customers who applied for open market cars for a debt consolidation.

2)Then merge that average with another average. Decide which field to merge on.
16 REPLIES 16
Reeza
Super User
Only the first part of your first question makes sense. The rest does not - remember we literally only see exactly what you post not your homework assignment so have no idea what you mean by 'Then use the summary to calculate the average of customers who applied for open market cars for a debt consolidation.'

Either ask very specific questions (How do I calculate the average mpg_city for the sashelp.cars data set for each Origin), or more generic questions (How to calculate an average for each group in a data set)
nhev
Fluorite | Level 6
Sorry the second question just meant use the average you just calculate and another average from another question and merge them together using 2 different variables roads and cara and also the method they used to apply debt consolidation and the question asking you to decide which average to merge first
Reeza
Super User

The "order" of a merge shouldn't matter unless you're filtering. 

Why do you think it matters? Does doing it different ways give you different results?

The fastest way to answer some of these types of questions is to try them both and see what works.

 


@nhev wrote:
Sorry the second question just meant use the average you just calculate and another average from another question and merge them together using 2 different variables roads and cara and also the method they used to apply debt consolidation and the question asking you to decide which average to merge first

 

PaigeMiller
Diamond | Level 26

Hello, @nhev, you have been asked to clarify and provide more detailed information. We really can't move forward without this information.

--
Paige Miller
nhev
Fluorite | Level 6
@Paige do you know by any chance how to use KEEP statement in SQL?
Kurt_Bremser
Super User

SQL does not have a KEEP statement or clause, but you can use the KEEP= dataset option on incoming and outgoing datasets.

In most cases, this is not needed, as you define the variables to be kept/created in the SELECT clause/statement.

nhev
Fluorite | Level 6
Thank you very much
nhev
Fluorite | Level 6
What about RENAME in sql?
PaigeMiller
Diamond | Level 26

@nhev wrote:
@Paige do you know by any chance how to use KEEP statement in SQL?

So far, one other person and myself have asked you to explain the problem in more detail. You are just going to ignore this request; and this is not a good way to get help on your problem. The people in this forum provide excellent help, but we can't help if you don't explain further.

 

Also, when the original problem talks about PROC SUMMARY and then you switch to SQL without providing a reason, then we are further confused. Again, confusing us is not a good way to get help.

--
Paige Miller
nhev
Fluorite | Level 6
It is just two different questions so I just didn’t switch from sql to proc summary but Thank you
nhev
Fluorite | Level 6
How can I calculate the average in a proc sql using group by statement?
Kurt_Bremser
Super User

@nhev wrote:
How can I calculate the average in a proc sql using group by statement?

Simple:

proc sql;
create table want as
  select
    sex,
    avg(age) as avg_age
  from sashelp.class
  group by sex
;
quit;
nhev
Fluorite | Level 6
It’s just a requirement of the question choosing what to merge first

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 16 replies
  • 1439 views
  • 0 likes
  • 5 in conversation