BookmarkSubscribeRSS Feed
James_Yu
Obsidian | Level 7

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.

9 REPLIES 9
Kurt_Bremser
Super User

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.

James_Yu
Obsidian | Level 7

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

James_Yu_0-1631109526951.png

 

Quentin
Super User

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.

 

 

 

 

The Boston Area SAS Users Group is hosting free webinars!
Next up: Joe Madden & Joseph Henry present Putting Power into the Hands of the Programmer with SAS Viya Workbench on Wednesday Nov 6.
Register now at https://www.basug.org/events.
James_Yu
Obsidian | Level 7
Do you have any idea of code to do that ?
I can use Proc report to output dataset in the form of my report but the data cells are already in character format like 20 (15.5%) for example.
Quentin
Super User

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 ;
The Boston Area SAS Users Group is hosting free webinars!
Next up: Joe Madden & Joseph Henry present Putting Power into the Hands of the Programmer with SAS Viya Workbench on Wednesday Nov 6.
Register now at https://www.basug.org/events.
DrAbhijeetSafai
Lapis Lazuli | Level 10

Excellent!

 

Thank you.

 

- Dr. Abhijeet Safai

Dr. Abhijeet Safai
Certified Base and Clinical SAS Programmer
Associate Data Analyst
Actu-Real
AllanBowe
Barite | Level 11

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.

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
Quentin
Super User

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

The Boston Area SAS Users Group is hosting free webinars!
Next up: Joe Madden & Joseph Henry present Putting Power into the Hands of the Programmer with SAS Viya Workbench on Wednesday Nov 6.
Register now at https://www.basug.org/events.
Tom
Super User Tom
Super User

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 9 replies
  • 5002 views
  • 15 likes
  • 6 in conversation