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

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

sasuser123123
Quartz | Level 8
Proc report data=dataset;
Column student Subject marks;
Define student/group;
Define subject/group;
Define marks/analysis sum;
Break after student/summarize;
Run;

Thank you!!
sasuser123123
Quartz | Level 8
May Be I gave the wrong data to you...
sasuser123123
Quartz | Level 8
Thank you so much Cynthia_Sas for your response..
Cynthia_sas
Diamond | Level 26
Do you still have a question or did your code work?
Cynthia
sasuser123123
Quartz | Level 8
It works...but ..Is there any wrong on that code??..as I told you the data which I gave you has some changes..not exactly like above data..

And One more question I've is..I need transpose of subject(it means math1 math2 math3) which consists marks like (math1marks math2marks math3marks)..
So I use across in define statement.. I'm getting Transpose output but it doesn't have marks values..it contains only number of math1 like 2.. math2 1
Would please help me on that one...I hope you understand my problem..
Cynthia_sas
Diamond | Level 26

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:

 

use_subject_across.png

  Otherwise, a better picture of what you want would be useful.

 

Cynthia

sasuser123123
Quartz | Level 8
Yes, exactly like in the pic and at the end of row I need total also...Thank you...
Cynthia_sas
Diamond | Level 26

You need to use an alias for MARKS to get a row total, like this:

use_alias_mtot.png

 

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

sasuser123123
Quartz | Level 8
I saw a question on Internet,in which there is a external file contains file like
01 apple orange grape
02 litchi guava
03 pineapple
04 orange apple peach
05 strawberry banana grape

So question is how many observations are produced by data step By reading this external file.
Answer is 12.
Would u please explain this one.?
Cynthia_sas
Diamond | Level 26
Hi:
It is impossible to answer your question without seeing the program that someone wrote to read the data and understanding what the logic in the program was.

Also, this sounds like a homework question. If so, I suggest you consult with your professor or teaching assistant for direction.

Cynthia
sasuser123123
Quartz | Level 8
Yeah sure
Thank you
Cynthia_sas
Diamond | Level 26

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:

read_data.png

 

  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

 

sasuser123123
Quartz | Level 8
I've a problem that I don't know how to do that problem...can u please
help me out;
data is like;;;
SUB FRUIT NAME
01 apple John
01 orange Suresh
01 Grape Naveen
01 kiwi Ayesha
02 melon suresh
02 pomegranate Ayesha
02 orange John
02 Guava Naveen

I need percentages and counts for each subject for each fruit like..

New_sub Sub01 sub02
JOHN X(%x) X(%x)
apple x(%x) X(%x)
orange X(%x) X(%x)
SURESH X(%x) X(%x)
orange X(%x) X(%x)
melon X(%x) X(%x)
NAVEEN X(%x) X(%x)
grape X(%x) X(%x)
Guava X(%x) X(%x)
AYESHA X(%x) X(%x)
kiwi X(%x) X(%x)
pomegranate X(%x) X(%x)

would you please help me out...
and how to do?
Cynthia_sas
Diamond | Level 26


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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 52 replies
  • 23288 views
  • 3 likes
  • 6 in conversation