Hi everyone, I just want to ask how to generate mock table in SAS.
I just found this topic Solved: Mock shell table in SAS - SAS Support Communities but the paper mentioned in there is about implying mock table when the shells have already been designed manually (in RTF file)
So my question is that: how can I generate a mock table in SAS in the first place ?
Thanks in advance.
Use a data step with a DATALINES block:
data want;
input string :$10. number date :yymmdd10.;
format date yymmdd10.;
datalines;
AAAAAAAAAA 12345 2021-08-31
BBBBBBBBB 567 2021-09-03
;
I included the most common data types.
I just want to create something like this.
Instead of real data, I want to just display xx.xx (for example) for demographic table, AE table, lab shift table,...
,
I would suggest simulating some data, then using your normal code to produce the table from the simulated data.
After that is done, I would try using formats that will format all values a "X" or "X.X%" or similar.
If you already have a PROC REPORT step which can make the table from a simulated data (or even real data), you can use PROC format to create a format which displays all the values as "XX", and then use that format in your PROC REPORT to mask the values.
Something like:
proc format ;
value X other='XX' ;
value $X other='XXX' ;
run ;
proc report data=sashelp.class ;
format _numeric_ x. _character_ $x.;
run ;
Excellent!
Thank you.
- Dr. Abhijeet Safai
You can mock a table using SAS code with DATALINES (also known as CARDS), or - if you'd like the ability to put your mocked table inside a macro - you can use INSERTS.
Whichever method you prefer, you can also generate the mocked data directly from an existing table. The following macros may help:
If you are generating mocks as part of a test suite, you might also be interested in sasjs test - a commandline approach for testing Jobs, Services and Macros in both SAS 9 and Viya.
"Table" has multiple meanings. Do you mean develop a mock table as as in mock SAS dataset? Or do you mean mock table as in a "table shell" that would go into the outline for a report (word doc or whatever)?
My thought for a report table shell would be to start by simulating a SAS dataset (either with CARDS to create data, or random number generators), and then running the usual reporting PROCS to generate the shell tables using ODS.
What do you consider a TABLE?
From the body of you message you mean a table (or figure) included in your analysis report.
If instead you meant a DATASET (what a lot of SQL terminology call a TABLE) then you are talking about something different.
In general for a mock report table structure you probably need a combination of datasets. One might be a mock set of sample data. And another might be a mock set of metadata to describe how the printed table should look.
You might even want to have a step that generates the sample data based on the metadata.
Your metadata might include titles, footnotes, number of treatment groups and other parameters that will impact how the tables will look.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.