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

Hi,

 

 I have a dataset with a variable that contains some numbers as "x.y" and others as "x,y".. and I would like to do a univariate analysis on that variable, but sas categorizes the ones with a comma in between as missing. I tried to convert the commas with Commax and comma and numx and nothing seems to Work! Also tried locale but that doesnt make a difference. Please help 🙂 What can be done?

 

Thanks in advance!

Janet

 

 My variable's name is s_result (it's a character and I converted it to numeric). The code is as such:

 

data dist2; set dist (rename=(s_result=s_result_char));

s_result=input(s_result_char, best.);

proc univariate; VAR s_result;

run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Use a conditional input:

data dist2; 
  set dist (rename=(s_result=s_result_char));
  if index(s_result_char,",") then s_result=input(s_result_char,comma.);
  else s_result=input(s_result_char,best.);
run;

proc univariate; 
  var s_result;
run;

Note not tested as no test data in the form of a datastep.  

View solution in original post

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Use a conditional input:

data dist2; 
  set dist (rename=(s_result=s_result_char));
  if index(s_result_char,",") then s_result=input(s_result_char,comma.);
  else s_result=input(s_result_char,best.);
run;

proc univariate; 
  var s_result;
run;

Note not tested as no test data in the form of a datastep.  

JanetJanbek
Calcite | Level 5

Thank you SO much. Worked!! 🙂

FreelanceReinh
Jade | Level 19

@JanetJanbek: Please wait. It's possible that your code ran without error messages, but used incorrect values! The COMMA. informat would not treat commas as decimal points. Better use NUMX. and compare the results.

 

 

Edit: Moreover, the COMMA and COMMAX informats have a default length of 1 (not 12 as NUMX.). So, without a length specification (e.g. COMMAX12.) they would read only the first character of the input string.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 715 views
  • 2 likes
  • 3 in conversation