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

I have a record with "7,5" is marked as string. When I try 

input("7,5", 8.) or input("7,5", best.)

it returns . or null number. What is the problem here? How could we solve it?

1 ACCEPTED SOLUTION

Accepted Solutions
ErikLund_Jensen
Rhodochrosite | Level 12

hi @vietlinh12hoa 

 

It can be read with a comma informat:

  • input("7,5",comma8.1);

But the comma format is very sensitive and makes factor 10 errors if there are no decimals or a different number of digits after the comma. So it is more secure to translate the comma to a point and use a standard numeric input format:

  • input(translate("7,5",'.',','), best.);

 

View solution in original post

3 REPLIES 3
ErikLund_Jensen
Rhodochrosite | Level 12

hi @vietlinh12hoa 

 

It can be read with a comma informat:

  • input("7,5",comma8.1);

But the comma format is very sensitive and makes factor 10 errors if there are no decimals or a different number of digits after the comma. So it is more secure to translate the comma to a point and use a standard numeric input format:

  • input(translate("7,5",'.',','), best.);

 

vietlinh12hoa
Obsidian | Level 7
Many thanks. It works
Amir
PROC Star

Hi @vietlinh12hoa,

 

Do you want to separate the numbers or interpret the comma as a decimal?

 

The following might help:

data want;
	/* separate the numbers */
	x = input(scan("7,5",1), 8.);
	y = input(scan("7,5",2), best8.);
	
	/* comma in place of decimal point */
	z = input("7,5",numx.);
run;

 

Thanks & kind regards,

Amir.

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
  • 2736 views
  • 0 likes
  • 3 in conversation