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

okay, thanks

Kurt_Bremser
Super User

Just to give you an impression what I mean by "visual formatting of code":

data want;
set have;

a = .;
b = .;
c = .;
d = .;

if typ_ill = :"cerv" or typ_ill = :"oval" then sex = 2;
else if typ_ill = :"pen" or typ_ill = :"test" then sex = 1;
else if typ_ill ^= :"cerv" or typ_ill ^= :"oval" or  typ_ill ^= :"pen" or typ_ill ^= :"test"
then do;
  sex = rand("integer",1,2);
  put sex;
end;

if a = . and b = . then do;
  a = rand("integer",1,12);
  b = rand("integer",1980,2000);
  c = rand("integer",1,2);
  d = rand("integer",1999,2019);
  output;
end;

if x = "8000" and a = "0" and y = " " then do;
  y = rand("integer",0,7);
  do while (y = 3);
    y = rand("integer",0,7);
  end;
  output;
end;
run;

Consistent indentation, consistent use (and non-use) of blanks, one statement per line.

Which one is easier to read and understand?

Anita_n
Pyrite | Level 9

Hello@Kurt_Bremser ,

thanks for your suggestion. It worked with using the put statement througout my code. Am very grateful

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 32 replies
  • 5807 views
  • 6 likes
  • 6 in conversation