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.
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.
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
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.
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.