I'm having trouble associating formats with a permanent SAS dataset. I am sure that I did create the format file. But when I run the attached SAS code, and then run PROC FREQ, the output is not formatted. The attached output.docx presents Race output as, e.g., 1, 2, 3 ... rather than the formatted "White", "African American", etc.
What am I doing wrong?
Thanks,
Dennis Hanseman
Most of us will not download and open Microsoft Office documents, they can be a security risk. Please include all of your SAS code, log and output in your reply as plain text (the output can be a screen capture). Do not use attachments.
Hi,
Many people will not open attachments, due to virus concerns. You will likely get more help if you edit your question to include the code you are running, as well as the log (are you getting any errors/warnings in the log)?
Please use the "running man" icon to insert SAS code into the message and the "insert code" button to insert your log text. This makes the code/log more readable.
I don't see any code where you are trying to attach the formats to the variables.
Try adding a FORMAT statement to your PROC FREQ.
Nor any code that would show what formats are currently attached to the variables.
Try running PROC CONTENTS on your dataset.
Finally you also do not have any code that would show use whether the values displayed in the PROC FREQ output are the raw values of the variable or the formatted values. Or any code to show the definition of the formats. You can use the FMTLIB option with PROC FORMAT to have it print the details of the format. You can use SELECT statement to limit the set of formats that it prints.
Code and log entries should be pasted as text. Open either a plain text box or a code box using the </> or "running man" icon that appears above the message window.
Example of how to simplify code (and use the text box). You have:
proc freq data=lib.cohort1; tables cohort; run; proc freq data=lib.cohort1; tables race; run;
Which requires SAS to load the same data set twice. You get the same output using:
proc freq data=lib.cohort1; tables cohort race; run;
With large data sets the time spent loading the data into the procedure could be noticeable. Even if you want to do different things with different variables you can use multiple tables statements in Proc Freq.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.