sub GRP Fruit Name
01 B apple NAVEEN
01 B grape SURESH
01 B guava BABU
01 B berry PAUL
02 C kiwi NAVEEN
02 C p-apple BABU
02 C orange AYESHA
03 A apple SURESH
03 A Tamota BABU
03 A orange SRI
03 A grape NAVEEN
04 B apple SRI
04 B kiwi AYESHA
04 B orange BABU
04 B p-apple PAUL
05 C potato NAVEEN
05 C apple SRI
05 C orange SURESH
OUTPUT should like...
NEW GRPA GRPB GRPC
NAVEEN count(%) count(%) count(%)
apple count(%) count(%) count(%)
kiwi count(%) count(%) count(%)
grape count(%) count(%) count(%)
potato count(%) count(%) count(%)
SURESH count(%) count(%) count(%)
grape count(%) count(%) count(%)
apple count(%) count(%) count(%)
orange count(%) count(%) count(%)
BABU count(%) count(%) count(%)
tamota count(%) count(%) count(%)
orange count(%) count(%) count(%)
PAUL count(%) count(%) count(%)
berry count(%) count(%) count(%)
p-apple count(%) count(%) count(%)
AYESHA count(%) count(%) count(%)
orange count(%) count(%) count(%)
kiwi count(%) count(%) count(%)
SRI count(%) count(%) count(%)
orange count(%) count(%) count(%)
apple count(%) count(%) count(%)
initially what i did is getting the counts of Name using proc freq
and then Fruit...but i didn't get the desired output..
would you please solve this one..
I hope You understand my data....
sorry for troubling you by asking again and again this one.actually i didn't get what you are saying and you gave an example which is not related to my problem..
Hi: Here's an example using SASHELP.CLASS.
The keywords for count and percent with PROC REPORT are N and PCTN. PCTN gives the percent of the grand total. SASHELP.CLASS has 19 observations so you can see that each percent is the number in the cell divided by 19. Then the percent9.2 format causes the multiply by 100 to make the percent value.
If you have 2 "sub groups" named SUB-01 and SUB-02, then you need to have an ACROSS item in your PROC REPORT COLUMN statement. You can nest N and PCTN under the ACROSS item, in this case the SUB variable, as shown below:
Since SASHELP.CLASS did not have a variable called SUB, I made one. SUB-01 group still has 19 observations, but SUB-02 value only has 13 observations. The percents for SUB-01 will be calculated by dividing by 19 and the percents for SUB-02 will be calculated by dividing by 13.
As you can see, the default behavior of PROC REPORT is to give 1 statistic per column. You CAN manipulate the values to make a new character variable that combines N and PCTN into 1 value like this 19 (100.00%), but that is something you would do AFTER you get a program similar to the above program working and that is the technique I show using COMPUTE blocks in my Creating Complex Reports paper that I referenced in my previous posting.
Cynthia
Hi:
There is always the possibility to get output the way you want -- however, based on what you've posted, I don't think you can create the desired output from the input data you show.
The challenge between what you show and what you want is that there's not really enough information or enough context for what you're trying to do to provide any suggestions. Here are my thoughts:
Your input data seems to be a jumble of State (TAMIL NADU, KARNATAKA and ANDHRA) combined with cities in one column. But I don't see, given that there's only 1 column in your data, how you can determine which cities go under which states in the output file.
As your input data stands, PROC SORT, PROC SQL, PROC REPORT, and PROC TABULATE will NOT give you what you want with only 1 column and the values jumbled together as they are. Perhaps if your data had a different structure or some kind of other identifier it would be possible. The only way I can see to produce your desired output is for you to manually associate the cities with each state.
Also, this seems to be a new question, and unrelated to the previous postings in this thread. In the future, it's probably better to open a new posting for a new question.
Cynthia
@sasuser123123 wrote:
I've a input data like.
State
TAMIL NADU
KARNATAKA
ANDHRA
Chennai
Arakkonam
Anantahpur
Vizag
Nellore
Mangalore
Bangalore
I need out put like
State
TAMIL NADU
Chennai
Arakkonam
ANDHRA
anantahpur
Vizag
Nellore
KARNATAKA
bangalore
Mangalore
Is there any possibilities to get the output like this ..
Yes, you create a new variable and then assign TAMIL NADU a value of 1 in the new variable, Chennai a value of 2 in the new variable, and so on; then sort by the new variable.
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 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.