BookmarkSubscribeRSS Feed
drfzLee
Calcite | Level 5

hey,

in onewayfreqs the ods output statement additionally creates this very useful variable named F_<nameoftablesvar> containing the formatted value, which is a copy of the displayed value.

is there anything like this in crosstabfreqs? 

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Did you look to see if it is in the output from CROSSTABFREQS?

--
Paige Miller
drfzLee
Calcite | Level 5

This is not the case. With the onyewayfreqs it comes automatically. Since it obviously doesn't come automatically with the crosstabfreqs, I thought there was another option to enable or something. But I could not find anything that would help me

 

What I want is a new variable that contains the formatted value of the original variable. I use the crosstabfreqs in a macro so the variables have different formats. In OneWayFreqs this was solved with the f_ variable. 

is there another way to create a new variable that contains only the format of another variable? This might be a better question.

Rick_SAS
SAS Super FREQ

If you require explicit F_ variables, you can use the PUT function to create them from the raw data and the formats for each variable. For example, the following program uses the 3.1 format for the variables A and B.  I use a DATA step view to create F_A and F_B that contain the formatted values:

 

/* generate example data */
data Have;
format A B 3.1;
call streaminit(1234);
do i = 1 to 100;
   A = rand("Table", 0.3, 0.5, 0.2);
   B = rand("Table", 0.1, 0.2, 0.3, 0.4);
   output;
end;
run;

proc freq data=Have;
tables A*B / out=FreqOut;
ods output CrossTabFreqs=CTF;
run;

/* add variables that contains the formatted values */
data Want / view=Want;
set CTF;
F_A = put(A, 3.1);
F_B = put(B, 3.1);
run;

proc contents data=Want;
ods select Variables;
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 496 views
  • 0 likes
  • 3 in conversation