BookmarkSubscribeRSS Feed
Rahul_SAS
Quartz | Level 8

Hello Experts,

 

Could you please explain the below code as I am not able to understand the kind of output its giving.

data temp;
format length width height 6.2;
array dimms lenght width height;
do j=1 to 10;
length = 100;
width = 50;
height = 30;
do i = 1 to 3;
dimms [i] = dimms[i] + normal (0)*2;
end;
output;
end;

In the below output, why i am getting 2 "lenght" variable? What is the use of "normal (0)*2"?

Why only first Lenght variable getting all 100s for all 10 observations however the other variables "width" and "height" are getting calculated values?

Rahul_SAS_0-1738083394544.png

Thanks

 

1 REPLY 1
PaigeMiller
Diamond | Level 26

The variable named LENGHT is probably a mis-spelling of LENGTH, and this improperly spelled variable appears in your code. This mis-spelled variable has never been assigned a value so you see it is always missing.

 

NORMAL(0)*2 is a random number generator, multiplied by 2.

 

LENGTH always has a value of 100 because nowhere in the code does the value get changed, probably because of the mis-spelling that I mentioned.

--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 431 views
  • 0 likes
  • 2 in conversation