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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 904 views
  • 0 likes
  • 3 in conversation