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