BookmarkSubscribeRSS Feed
yadalsa
Calcite | Level 5

Hi Team,

Iam using Proc Report for creating a table. I have created a small dataset. i have 4 levels of a variable (L,P,S,W) and then sub_types within each level

O,V,U

the desired output is attached. Iam trying to find frequencies of only the 1's, Iam not interested in the 0's

Also, is there a way to output the data in a desired fashion, for eg.,

i want par6, par7 and part8 to be followed by part1 etc.,

 

Thank you,

 

7 REPLIES 7
Reeza
Super User
You should post some sample data in addition. Also, please don't double post your question to multiple forums.

You won't get a dataset in that fashion, but you will get output displayed in that manner. Please clarify which is your desired output, I'm assuming the display since you can't have multiple headers for variables.
yadalsa
Calcite | Level 5

Hi Reeza,

I created a dataset and an output but i was not able to post 2 spreadsheets. i have the dataset and the output in one spreadsheet in different tabs. Hopefully this should give us a better picture. 

Thank You.

Astounding
PROC Star

When you have a variable that is always 0 or 1, change the approach.  To get a single statistic per variable:

 

To get the frequencies of the "1" values, get the sum.

 

To get the percentage of "1" values, get the mean.

 

You may have to adjust your computations, if your variable could take on other values, such as a missing value.

 

Good luck.

yadalsa
Calcite | Level 5

Thank You very much.

Reeza
Super User
1. As mentioned, when you have 0/1 you can sum
2.To control order you need to create a variable that corresponds to the order and then use that to control the order.
3. You didn't answer the question - do you need this as output or a dataset?
yadalsa
Calcite | Level 5

hi Reeza,

i think i figured it out, i ran a means within the table statement. 

 

Thank you

 

 

proc tabulate data = test out = test1; by procedure1;

var par1 par2....;

class type sub_type;

table all*n (par1 par2 ) *mean = '' *f=pct100fmt.

, type = '' * sub_type= ''  /nocellmerge;

run;

 

Reeza
Super User
Yay! Glad to see it worked for you 🙂

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 7 replies
  • 2200 views
  • 0 likes
  • 3 in conversation