BookmarkSubscribeRSS Feed
Chikku
Calcite | Level 5

Hi All,

To read the below percent field used this format which works fine.But I want to know how exactly the percentw.d format is woking internally because i have not understood how it is storing and displaying the percent data with some examples.

informat percentofmarks percent6.;

format percentofmarks percent8.2;

---------------------------------------------------

studentname Standard percentageofmarks

syed 6 67.25%

----------------------------------------------------

Please describe this.

Thank you:)

3 REPLIES 3
Fugue
Quartz | Level 8

The percentw.d informat instructs SAS to read data containing percentages as numeric. Refer to https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000204437.htm

The percentw.d format does the opposite, it writes numeric data as percentages. Refer to https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000205182.htm

Tom
Super User Tom
Super User

Percentages are stored as the number you would use in mathematical operations. So 50% is stored as 0.5.

36   data test;

37     informat percentofmarks percent6.;

38     format percentofmarks percent8.2;

39     input studentname $ Standard percentofmarks ;

40     put percentofmarks = best12. ;

41     put percentofmarks = percent8.2 ;

42

43   cards;

percentofmarks=0.6725

percentofmarks=67.25%

Peter_C
Rhodochrosite | Level 12

beware the D in any INFORMATw.d

INPUT will assume the last "d" digits are decimal places even when you have no dot!

158  data;

159  input percD percent6.1 @1 perc_noD percent6. @1 str_ $ ;

160  put (str_ perc: perc:)( $8. 2*percent9.1  2*best9.) ;

161  cards;

12.1%      12.1%    12.1%     0.121    0.121

12%         1.2%    12.0%     0.012     0.12

NOTE: The data set

the D in informatW.D  is really only there for binary informats which cannot present the dot

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!

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
  • 1805 views
  • 0 likes
  • 4 in conversation