BookmarkSubscribeRSS Feed
baltes
Calcite | Level 5

I am a SAS novice. I have two fields called P_ADJ_INCOME and S_ADJ_INCOME where the output are negative values like:  -000680 and I would like to reformat this output to: 00-0680

for reporting purposes.

I would appreciate your help!

 

3 REPLIES 3
ballardw
Super User

If you values are not exactly 6 digits and integer then you will need to provide a larger example of values and how they should appear.

You may also have to provide an example just how you are building your "report".

baltes
Calcite | Level 5

In both fields, the output is exactly 6 digits including the dash. They all look like this: 


-005236
-025450
-003629

PGStats
Opal | Level 21

Use a picture format:

 

data have;
do x = -005236,-025450,-003629,-000077;
    output;
    end;
format x z7.;
run;

proc format;
picture myFormat 
low-high='99-9999';
run;

data want;
set have;
y = x;
format y myFormat.;
run;

proc print data=want; run;
Obs. 	x 	y
1 	-005236 	00-5236
2 	-025450 	02-5450
3 	-003629 	00-3629
4 	-000077 	00-0077
PG

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!

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