BookmarkSubscribeRSS Feed
amar8580
Calcite | Level 5

hi all

i am new to sas

i have been trying to create a report using this code but its not working properly

proc report data=work.test;

columns product state city;

define product /group;

define state /across

define city /across;

run;

results come out as

                              california     new jersey       los angeles     trenton

product 1

whereas i want the output to look like this

                              california           new jersey

                              los angeles         trenton

product 1

any idea how i achieve that

i want the across one underneath the other so it looks like grouping and not one after the other

1 REPLY 1
ballardw
Super User

I don't do will with nesting in proc report which it looks like you may be doing. If the only thing you are looking for are simple counts and may have multiple cities per state then I would try proc tabulate:

proc tabulate data=work.test;

     class product, state, city;

     tables product, state*city*n=''*f=best8.;

run;

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
  • 1 reply
  • 420 views
  • 0 likes
  • 2 in conversation