BookmarkSubscribeRSS Feed
Gauri123-56
Fluorite | Level 6
I want to create 2 different macros for getting proper alignment in tables of clinical sas like for count and percentage so that they will come with same alignment in final report.
Help will be appreciated😊
6 REPLIES 6
Kurt_Bremser
Super User

The macro language is for creating dynamic, reusable code. So you first need working base SAS code.

Please show that code, and indicate which parts need to be made dynamic.

Gauri123-56
Fluorite | Level 6
Here this space between count and percentage I'm giving manually for each variable so i want to create macro for that which will give proper alignment for both character as well as numeric variables
PaigeMiller
Diamond | Level 26

@Gauri123-56 wrote:
Here this space between count and percentage I'm giving manually for each variable so i want to create macro for that which will give proper alignment for both character as well as numeric variables

That's great, but many of us will not download file attachments. Use the "Insert Photos" icon to show us a screen capture of what you want us to see. And please also provide the other information that we have requested.

 

Also, what does any of this have to do with macros?

--
Paige Miller
Kurt_Bremser
Super User

"Alignment" is only relevant in reports. Your code does not produce a report. You will also not need a macro to get correct alignments in a report procedure.

Please post usable example data (data step with datalines, posted as code-text, NOT as a picture!) and the report layout you want to achieve (this may be a screenshot).

PaigeMiller
Diamond | Level 26

Agreeing with @Kurt_Bremser , you need working code without macros and without macro variables before you start macro writing. If you don't can't write working code without macros and without macro variables, then you can't write a macro that works. People sometimes avoid/ignore this advice, but honestly, you can't get anywhere if you avoid this advice. So show us working code without macros and without macro variables.

--
Paige Miller
ballardw
Super User

@Gauri123-56 wrote:
I want to create 2 different macros for getting proper alignment in tables of clinical sas like for count and percentage so that they will come with same alignment in final report.
Help will be appreciated😊

With out very explicit details, such as your data and the actual appearance of the report there really isn't any way to answer this.

HOWEVER, I have seen enough of these "count and percentage" requests over the years to say that if you want both to appear in ONE cell of a table,  such as "123 (43.5%)" as a single value, that you will spend a great deal of effort trying to get anything to "align" nicely. Procs Report, Tabulate and Print, the basic tools for reporting, include alignment options for each cell of a report table. So if each value is alone in a cell you can get consistent alignment.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

LIBNAME 101

Follow along as SAS technical trainer Dominique Weatherspoon expertly answers all your questions about SAS Libraries.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 6457 views
  • 6 likes
  • 4 in conversation