Hi:
Thanks for posting some data, but what PROC REPORT code have you tried? What is your destination of choice for the output report? HTML, RTF, PDF???
Also, I'm confused by your output. A01 student does not have any rows for Math2 or Math3. Why do you show student A01 on the output, but not the other students? That doesn't make sense to me. Either you want to see all the students and their summarized scores or you don't want the students. It doesn't make sense to me to only show A01 and not student A02 or A03.
Cynthia
Hi:
I'm not entirely sure I understand what you need. It sounds to me like you want a separate column with the sum of the Math1 marks, the Math2 marks, etc. Possibly like this:
Otherwise, a better picture of what you want would be useful.
Cynthia
You need to use an alias for MARKS to get a row total, like this:
Essentially, you are using MARKS first, under each SUBJECT to get the sum of the marks for each subject and next you are using MARKS a second time on the report to get the total at the end of each row. This second time, MARKS will be referred to in a DEFINE statement as MTOT.
Cynthia
Hi:
There are 2 possible ways to read the data. With one method, you would get 5 observations; with the other method, you would get 12 observations:
So 12 is a possible answer, but since there is another way to read the file, it's impossible to say absolutely that 12 is the answer without knowing whether the program created one observation for every row in the raw data file or whether the program created one observation for every value of fruit in the raw data file.
In fact, there is a third way to read the file and get 15 observations, if you assume that there can be a max of 3 fruits per row in the raw data file. But without seeing the program to read the data, it's impossible to say what the correct answer is to the question you posted.
Cynthia
Hi:
Your first challenge will be to read the data. What does your program to read the data look like? Does it work as you expect? Then, once you have a working program that reads the data, your best resource for calculating the N and the PCTN will be either PROC FREQ or PROC TABULATE or PROC REPORT.
I see that you have 2 values for Count and Percent showing in your desired output. But I don't understand how, given your data, that you would calculate either your SUB01 or your SUB02.
Typically, however, with SAS Procedures, you cannot get numbers like X(XX%) in one cell. Usually, you need to capture the COUNTs and the PERCENTs separately and then concatenate them together to cosmetically display as 10 (50%) or something similar.
There is a paper I wrote called Creating Complex Reports https://support.sas.com/rnd/papers/#SGF2008 (there are 2 links under the paper title -- one for the paper and one for the zip file) that illustrates how to create a demographic report that is similar to what you show, but I was starting from a SAS dataset in my paper and it looks like you're starting from data lines and don't have a clear idea of how SAS Procedures work to calculate Counts and Percents.
Taking the free Programming 1 class might help you figure out task #1 (how to read your data) and then task #2 (to get counts and percents) and then once you do that, making the report you want will be a matter of understanding what the SAS procedures give you by default and how you may have to manipulate what you get in order to create the report you want.
Cynthia
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.