BookmarkSubscribeRSS Feed
BruceBrad
Lapis Lazuli | Level 10

I want to print values like 1360 as 1.4 (thousand). Can this be done with formats, or do I have to calculate values?

Eg the following code, gives an output of

v1=1.3 v2=1.4

But I want v1 to look like v2.

proc format;

picture thousands low-high='000,000,000.9' (mult=.01);

data test;

v1 = 1360;

v2 = v1/1000;

format v1 thousands.;

format v2 comma10.1;

put v1= v2=;

run;

3 REPLIES 3
SASKiwi
PROC Star

Perhaps something like this?

proc format   

picture thousands (ROUND)

LOW-<0  = '000,000,000,009.9'  (PREFIX='-' MULT=0.001)

0-HIGH = '000,000,000,009.9'  (MULT=0.001);

run;

BruceBrad
Lapis Lazuli | Level 10

(Almost) perfect. I had missed the Round option. But (as I've just realised after testing) not quite correct. The mult options should be 0.01 not 0.001 to get thousands when you have one decimal place.

So the format should be

proc format;

picture thousands (ROUND)

   LOW-<0  = '000,000,000,009.9'  (PREFIX='-' MULT=0.01)

   0-HIGH = '000,000,000,009.9'  (MULT=0.01);

run;

BrunoMueller
SAS Super FREQ

Hi

Have a look at this discussion  it shows how to create your own rounding function, and then package this into a format. For your example, I guess you need to divide the rounded value by 1000.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3409 views
  • 4 likes
  • 3 in conversation