BookmarkSubscribeRSS Feed
Nasya
Obsidian | Level 7

 Hi,

Is there a way to remove the leading spaces for the decimal values without making any changes to the  original value.

Below is the dataset

ID               DOSE 

001                         0.20000

002                          0.40000

 

I wish to remove the leading spaces and am expecting output as below:

ID               DOSE 

001             0.20000

002             0.40000

Further information about the variables:

ID:Label is "Subject ID' and is a character variable, length=150

DOSE: Label is 'Dose' and is a numeric variable with format 31.5, length=8

Thank you,

 

Regards,

Nasya

 

6 REPLIES 6
ballardw
Super User

You might mention where you are viewing your numeric variable. There actually are NO leading spaces. The format you have for that variable 31.5 tells SAS to display the value using 31 spaces with 5 decimal places. You can change appearance by changing the format. From the values you show a format of perhaps 5.1 or best5. might work. Formats can be permanently changed by using a FORMAT statement in data step or proc sql code that creates or uses the variable; in proc datasets to modify a data set in place; using SAS Explorer to examine properties and manually changing them. And format can be specified for specific use at time to change display for that procedure using a FORMAT statement in the procedure code.

 

If the appearance of concern is in some output such as proc print or report you should change the justification with a style override to show the values as left justified. By default SAS will display numeric values as right justified which may cause an appearance of "spaces".

 

Something in your process is kind of odd that your ID variable has a character 150 long though.

Nasya
Obsidian | Level 7

Hi,

Thank you for your detailed response. Yes I am unable to left justify the output values for Dose. 

This is the complete Subject ID's 01-ABJC-001 and 02-ADGH-002 of how they appear in the dataset.

The following is written in the Proc Report to left justify, still futile.

 

define DOSE /left flow "Dose (mcg/kg/min)"
style(column)=[cellwidth=12% asis=on]
style(header)=[just=left];

 

Any suggestions on the above?

Thank you,

 

Regards,

Nasya

Nasya
Obsidian | Level 7

Thank you for the detailed response, Yes, the issue is in displaying the output in the PROC REPORT.

 

define DOSE /left flow "Dose (mcg/kg/min)"
style(column)=[cellwidth=12% asis=on]
style(header)=[just=left];

The above is the part of the proc report given for the DOSE value, still it is not left justified. Am I missing anything here?

About the SUBJECT ID, the complete Subject ID's are 01-AHJL-001 and 02-AGYR-002.

Thank you,

 

Regards,

Nasya

 

 

 

 

Reeza
Super User

The format is numeric, there is no leading spaces. Do you want it left aligned instead? By convention, character variables are aligned left and numeric are aligned right. I suspect the best decision is to align the DOSE title to the right as well. How are you displaying the variables?

 


@Nasya wrote:

 Hi,

Is there a way to remove the leading spaces for the decimal values without making any changes to the  original value.

Below is the dataset

ID               DOSE 

001                         0.20000

002                          0.40000

 

I wish to remove the leading spaces and am expecting output as below:

ID               DOSE 

001             0.20000

002             0.40000

Further information about the variables:

ID:Label is "Subject ID' and is a character variable, length=150

DOSE: Label is 'Dose' and is a numeric variable with format 31.5, length=8

Thank you,

 

Regards,

Nasya

 


 

Nasya
Obsidian | Level 7

Yes, I have issue while being displayed in the Proc Report. The Dose values are not being left justified when the below is mentioned.

 

define DOSE /left flow "Dose (mcg/kg/min)"
style(column)=[cellwidth=12% asis=on]
style(header)=[just=left];

 

Am I missing anything here?

ballardw
Super User

@Nasya wrote:

Yes, I have issue while being displayed in the Proc Report. The Dose values are not being left justified when the below is mentioned.

 

define DOSE /left flow "Dose (mcg/kg/min)"
style(column)=[cellwidth=12% asis=on]
style(header)=[just=left];

 

Am I missing anything here?


An entire procedure and data set.

If you want the cell values left justified along with the header you would use style=[just=left]

I'm not quite sure why you have asis=on though.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 6 replies
  • 5924 views
  • 1 like
  • 3 in conversation