turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Health Care and Pharma
- /
- SAS in Health Care Related Fields
- /
- Quiz/ Challenging problem?

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-07-2008 06:10 AM

Find square root of any positive real number without using any function (like sqrt).

Basic arithmetic operators (addition,subtraction,multiplication & division) are allowed. Use only SAS programming.

Thanks,

Anil

Basic arithmetic operators (addition,subtraction,multiplication & division) are allowed. Use only SAS programming.

Thanks,

Anil

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-07-2008 07:41 AM

Homework problem? Or did you make a bet with someone?

Exponentiation is expressed with two multiplication symbols.

So, adjust the exponent value for the power you want to apply.

I seem to recall this was early high school maths.

Exponentiation is expressed with two multiplication symbols.

So, adjust the exponent value for the power you want to apply.

I seem to recall this was early high school maths.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-07-2008 12:15 PM

David has an excellent idea. Try:

1 data _null_;

2 sqrt = 2**(-.5);

3 put sqrt;run;

0.7071067812

1 data _null_;

2 sqrt = 2**(-.5);

3 put sqrt;run;

0.7071067812

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-07-2008 11:56 PM

Thanks for the solution.

The use of expoenetial is not allowed.

The SAS program should have only addition,subtraction,multiplication and division mathematical operators.

Thanks

The use of expoenetial is not allowed.

The SAS program should have only addition,subtraction,multiplication and division mathematical operators.

Thanks

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-08-2008 01:42 AM

Hi:

Interesting problem. I remember that when my daughter went to Montessori school, they had a way of calculating square roots through some kind of repetitive division method.

Apparently, it's a popular topic out on the math forum:

http://www.nist.gov/dads/HTML/squareRoot.html

http://math.arizona.edu/~kerl/doc/square-root.html

http://en.wikipedia.org/wiki/Square_root

http://mathforum.org/library/drmath/view/52609.html

http://www.bbc.co.uk/dna/h2g2/A827453

http://mathforum.org/library/drmath/view/52610.html

http://mathforum.org/library/drmath/view/51890.html

Once you know the algorithm, it should be fairly simple to code in a data step program...although, it seems a sort of an odd exercise, when ** works quite nicely.

cynthia

Interesting problem. I remember that when my daughter went to Montessori school, they had a way of calculating square roots through some kind of repetitive division method.

Apparently, it's a popular topic out on the math forum:

http://www.nist.gov/dads/HTML/squareRoot.html

http://math.arizona.edu/~kerl/doc/square-root.html

http://en.wikipedia.org/wiki/Square_root

http://mathforum.org/library/drmath/view/52609.html

http://www.bbc.co.uk/dna/h2g2/A827453

http://mathforum.org/library/drmath/view/52610.html

http://mathforum.org/library/drmath/view/51890.html

Once you know the algorithm, it should be fairly simple to code in a data step program...although, it seems a sort of an odd exercise, when ** works quite nicely.

cynthia

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-08-2008 02:09 AM

Thanks a lot for your references.

This is a problem which is given to new sas learners to understand ' concept algorithm'.

Even though most of the students have understood algorithm,not a single

experienced SAS programmer could write a SAS program.

This is the reason to post this problem.

Experienced SAS programmers are requested to help.

Thanks in anticipation.

Anil

This is a problem which is given to new sas learners to understand ' concept algorithm'.

Even though most of the students have understood algorithm,not a single

experienced SAS programmer could write a SAS program.

This is the reason to post this problem.

Experienced SAS programmers are requested to help.

Thanks in anticipation.

Anil

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-08-2008 09:32 AM

guess this is like getting an abacus to calculate square roots.

(well how did the ancient greek and egyptian architects and engineers achieve so much without our technology? - I guess they knew how to use their own! )

A long time ago in school we calculated square roots with iterative long-division

Later at university "expansion of series" achieved the mathematical equivalent

Now it's just easier to use the simplest formula

as "an experienced sas programmer" I'm not sure why I should care !

I remain to be persuaded

PeterC

(well how did the ancient greek and egyptian architects and engineers achieve so much without our technology? - I guess they knew how to use their own! )

A long time ago in school we calculated square roots with iterative long-division

Later at university "expansion of series" achieved the mathematical equivalent

Now it's just easier to use the simplest formula

as "an experienced sas programmer" I'm not sure why I should care !

I remain to be persuaded

PeterC

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-08-2008 11:03 AM

I can see how it would be a good exercise for a new sas learner. It would help them figure out iterative processing, SAS functions, and the order of operations as well as teaching them how to deal with the situation of 1 square root being calculated vs having a file of numbers for which sq rts needed to be calculated.

My general policy on posting code is that if I have a sample program that can be easily changed to illustrate a point, I will post the code. I read the algorithm and I have a general idea of how to write the program.

But there's no benefit for me to write the program. Part of the learning process, in general is understanding the problem and solving it in concept. Then once you understand the solution in concept, if you have to go a step further and write code, then the best way to LEARN is to try something, try something else, make some progress, make some mistakes, read some documentation, try something and read some more documentation (gee, I need a way to break this number into "chunks" -- let me look at the list of SAS functions), and try something else.

At any rate, this question really is off topic for SAS and clinical trial questions and doesn't really belong in this forum.

cynthia

My general policy on posting code is that if I have a sample program that can be easily changed to illustrate a point, I will post the code. I read the algorithm and I have a general idea of how to write the program.

But there's no benefit for me to write the program. Part of the learning process, in general is understanding the problem and solving it in concept. Then once you understand the solution in concept, if you have to go a step further and write code, then the best way to LEARN is to try something, try something else, make some progress, make some mistakes, read some documentation, try something and read some more documentation (gee, I need a way to break this number into "chunks" -- let me look at the list of SAS functions), and try something else.

At any rate, this question really is off topic for SAS and clinical trial questions and doesn't really belong in this forum.

cynthia

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-08-2008 11:34 PM

Dear All,

Thanks a lot for your replies.

As this is offttopic for SAS and clinical trial questionsI want to clse the issue.

Anil

Thanks a lot for your replies.

As this is offttopic for SAS and clinical trial questionsI want to clse the issue.

Anil