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.

 

 

 

 

BASUG is hosting free webinars Next up: Mark Keintz presenting History Carried Forward, Future Carried Back: Mixing Time Series of Differing Frequencies on May 8. Register now at the Boston Area SAS Users Group event page: 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 ;
BASUG is hosting free webinars Next up: Mark Keintz presenting History Carried Forward, Future Carried Back: Mixing Time Series of Differing Frequencies on May 8. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
DrAbhijeetSafai
Pyrite | Level 9

Excellent!

 

Thank you.

 

- Dr. Abhijeet Safai

Dr. Abhijeet Safai
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.

BASUG is hosting free webinars Next up: Mark Keintz presenting History Carried Forward, Future Carried Back: Mixing Time Series of Differing Frequencies on May 8. Register now at the Boston Area SAS Users Group event page: 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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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