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

Hi Tom,

I need one more guidance on the proc frequency.  I have report to be generated with 250 attributes or variables. in the below code i want the attributes to keep changing till 250 automatically and get the combination. is there any way or do i need to hardcode.

proc freq;

tables brand*market*aa1*(attrib1)*b5_own /noprint out=freq ;

weight weight ;

run;

What i am currently doing is

%macro attrib;

proc freq;

tables brand*market*aa1*(&attributes)*b5_own /noprint out=freq ;

weight weight ;

run;

%mend attrib;

%attrib (attributes= attrib1 attrib2 attrib3.....till attrib250).

Can you please guide is there any smarter way to do this?

Thanks and Regards,

S.S.Pradeep

Tom
Super User Tom
Super User

If your variables are named with numeric suffixes as in your example then you can use variable list syntax.

attrib1 - attrib250

If not, but you know the physical order of the variables in the dataset then you can use -- between the names

age -- race

srisaipradeep
Calcite | Level 5

Hi Tom,

Thank you for the guidance. As you suggested Proc summary is the best choice. I tried running both proc freq and proc summary.

1. Proc freq - i got the percent frequency count and percentage of total frequency in the output dataset - so if i remove the noprint option and run i am getting the exact number which i am looking out for.

2. proc summary - here i got the type , freq and weight in the output dataset. how can i go about in converting or transpoing the dataset to the exact percentage i am getting in proc freq.

Please guide,

Thanks and Regards,

S.S.Pradeep

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
  • 17 replies
  • 4493 views
  • 10 likes
  • 5 in conversation