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

Good day SAS friends:

 

I need to know how to name this variable in the example, im working in categorical variables, so when the sample has no decimal characters, this means succes ("1") and when the characters have decimal characters means no succes ("0").

 

here is the data set and my programming (help me to fix it please):

 

data main;
input sample;
cards;
23

24

25

26.7

28

28.1

28.2

28.3
;
run;

data want;

set have;
z = .;

if sample = (number with no decimals)

then do;

z = 1;

result = "Succes!";
end;
else if x = (number with decimals) then do;

z = 0;

result = "No Succes";
end;
run;

proc print data=want;
var sample z result;
run;

 

Thank you very much

 

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

If your data came in as numeric as you presented:

 

data main;
	input sample;
	cards;
 23
24
25
26.7
28
28.1
28.2
28.3
;
run;

data want;

set main;

length result $ 10;

z=sample=int(sample);

result=ifc(z=1,'success', 'no success');

run;

 

View solution in original post

3 REPLIES 3
slchen
Lapis Lazuli | Level 10
data want;
   set main;
   z=0;
   result='No Succes';
   if index(sample,'.') then do;
     z = 1;
     result = "Succes!";
  end;
run;
Haikuo
Onyx | Level 15

If your data came in as numeric as you presented:

 

data main;
	input sample;
	cards;
 23
24
25
26.7
28
28.1
28.2
28.3
;
run;

data want;

set main;

length result $ 10;

z=sample=int(sample);

result=ifc(z=1,'success', 'no success');

run;

 

jonatan_velarde
Pyrite | Level 9

Awesome

 

Thank a lot !!!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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