BookmarkSubscribeRSS Feed
DATA_ALAN
Calcite | Level 5

Trying to produce a table that is exactly as shown. Can this been done with Proc Format and only one other procedure? Or do I need to setup the dataset to get the look at want when using something like proc tabulate?

 

Characteristic is the variables names and the Group is the variable values. (N is the counts and % is the percent of Characteristic)

 

 

Update: Proc Format is taken care of. The second image is what I got so far. I need the varable names in a seperate column to the left just like the from the first image.


Untitled.jpgUntitled2.jpg
3 REPLIES 3
LinusH
Tourmaline | Level 20
What will be the values?
Spontaneously I see three separate tables, probably generated by PROC TABULATE.
One way to solve this is to store the output of each tabulate in common data set, and then PROC PRINT that.
Data never sleeps
Shmuel
Garnet | Level 18

It seems to me that you need 3 different formats:

   (1) for gender, (2) for age group, (3) for employment

 

Usually a format usage is to convert or display a text instead of a code,

but I don't see codes in your table.

 

Anyway, you may try use or addapt next proc format:

 

proc format lib=work;  /* you can use another library */

      value $gender      /* $ for chracter format */

          'F' = 'Female'

          'M' = 'Male'

       ;

     value age_dec

          2 = '20s'

          3 = '30s'

          ...

          6 = '60+'

       other = '??'    /* undefined */

     ;

     value $employ

        'Full' = 'Full Time'

        'Part' = 'Part Time'

      ;

   run;

 

Having the formats, you can use Proc Tabulate (or other procedures, depending on your dataset)

to displaty the data in the format you show. For more help - attach an example of your data or dataset.

 

 

Reeza
Super User

You can do it solely with Proc Tabulate and formats. This is the easier method.

 

Proc Freq is another option as well with a bit of manipulation. You would add the formats for the variables into the proc freq.

 

*Run frequency for tables;
ods table onewayfreqs=temp;
proc freq data=sashelp.class;
	table sex age;
run;

*Format output;
data want;
length variable $32. variable_value $50.;
set temp;
Variable=scan(table, 2);

Variable_Value=strip(trim(vvaluex(variable)));

keep variable variable_value frequency percent cum:;
label variable='Variable' 
	variable_value='Variable Value';
run;

*Display;
proc print data=want(obs=20) label;
run;
Sign up for free

 

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
  • 3 replies
  • 901 views
  • 1 like
  • 4 in conversation