BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
WilliamB
Obsidian | Level 7

Hello,
I have a database (.txt) made up of percentage:

50 

40

20

10

41

But they must not be in this form

Which format or informat would allow to have this in sas table :

0.5%

0,4%

0,2%

0.1%

0,41%

 

Thanks for your help

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Depending upon what you actually want, here is an example of the percent format and informat on your example data:

data have;
  informat percent1 percent3.2;
  informat percent2 percent3.3;
  informat percent3 percent3.4;
  format percent1-percent3 percent6.2;
  input @1 percent1 @1 percent2 @1 percent3;
  x1=10*percent1;
  x2=10*percent2;
  x3=10*percent3;
  cards;
50 
40
20
10
41
;

Art, CEO, AnalystFinder.com

 

View solution in original post

3 REPLIES 3
jklaverstijn
Rhodochrosite | Level 12

If you print these numbers using the PERCENT. format that is what you will get. Please be aware that it is not how you store the numbers in the table that determine how they are printed. That is what is controlled by the format definition. So SAS separates the data and the presention. As this is an important concept I advise you to read up on formats and informats.

 

Hope this helps,

-- Jan.

art297
Opal | Level 21

Depending upon what you actually want, here is an example of the percent format and informat on your example data:

data have;
  informat percent1 percent3.2;
  informat percent2 percent3.3;
  informat percent3 percent3.4;
  format percent1-percent3 percent6.2;
  input @1 percent1 @1 percent2 @1 percent3;
  x1=10*percent1;
  x2=10*percent2;
  x3=10*percent3;
  cards;
50 
40
20
10
41
;

Art, CEO, AnalystFinder.com

 

Astounding
PROC Star

Are you sure this is what you want?  The math is off here.  Even if the number 50 refers to 50 percent, you can represent that as either 50% or 0.5.  But 0.5% means something different.

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