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

Hi SAS communities,

I have a database that has the population by 110 ages, 50 states and 2 sexes, meaning my database had 110x50x2 rows.

I would like to create extra rows that would contain all the possible combinations for  "all ages combined ", "all states combied " and "both sexes"

The new database would have 111x 51 x3 rows.   Is there an easy way to do this?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
morglum
Quartz | Level 8

Proc TABULATE is the answer.  I was so focussed on thinking up a proc sql way that I forgot the obvious:

proc tabulate data= pop out=tabulated;

class age  sex state year ;

var pop;

table (age all) * (sexe all) * (state all) * (year), weight=' ';

run;

View solution in original post

3 REPLIES 3
LinusH
Tourmaline | Level 20

Storing total rows in a  database in not recommended. Have them calculated during report creation instead.

Data never sleeps
morglum
Quartz | Level 8

Hi Linus,

I am in the report creation phase, how would you proceed to generate all these lines?

I may be missing something obvious like a proc freq or tabulate.

I just want the output to be a sas7bdat file.

morglum
Quartz | Level 8

Proc TABULATE is the answer.  I was so focussed on thinking up a proc sql way that I forgot the obvious:

proc tabulate data= pop out=tabulated;

class age  sex state year ;

var pop;

table (age all) * (sexe all) * (state all) * (year), weight=' ';

run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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
  • 3 replies
  • 1467 views
  • 3 likes
  • 2 in conversation