DATA Step, Macro, Functions and more

Variable validation

Accepted Solution Solved
Reply
PROC Star
Posts: 633
Accepted Solution

Variable validation

Assume I have a variable called "amount" and it has values like -15.59000, -1125.59000 etc and the format NLNUM18.5 has already been applied on that variable. Is there any way to verify that this variable is not displaying the values in exponential notation?

 

I find difficult to manually verify the values (it has over 10L unique values) for this variable.

 


Accepted Solutions
Solution
‎02-15-2018 01:20 AM
Super User
Super User
Posts: 9,840

Re: Variable validation

Put the data into text, do a lengthn() function on it:

data test;
  length test $200;
  set have;
  test=put(nlnum,best.);
  check=lengthn(test);
  if check > 18;
run;

Note, as always, post test data in the form of a datastep, I cannot test the above code.

View solution in original post


All Replies
Frequent Contributor
Posts: 112

Re: Variable validation

Print the Variable amount into a text file.

In printing into text file SAS prints the value as it is displayed format in the table.

Search for E in the file.

 

This had worked for me.

If you have some E then try rounding off the value to your desired decimal places.

Valued Guide
Posts: 629

Re: Variable validation

Posted in reply to Satish_Parida

The function vvalue returns the formatted value of a variable. Maybe exporting the data can be skipped by using that function. Can't test it now, just an idea.

Solution
‎02-15-2018 01:20 AM
Super User
Super User
Posts: 9,840

Re: Variable validation

Put the data into text, do a lengthn() function on it:

data test;
  length test $200;
  set have;
  test=put(nlnum,best.);
  check=lengthn(test);
  if check > 18;
run;

Note, as always, post test data in the form of a datastep, I cannot test the above code.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 117 views
  • 1 like
  • 4 in conversation