Can someone please help me answer this question.
Write code in SAS that allows one to write to a csv file a data set with all natural numbers less than a given parameter N as well as a boolean variable indicating if the number is perfect or not.
So the CSV must contain
1, False
2, False
6 True
Im a first time SAS user and I cant seem to go anywhere with this.
Seems like a very difficult problem for a first-time user.
This paper can help: https://support.sas.com/resources/papers/proceedings15/3384-2015.pdf
You might want to recheck the statement of the problem. A common programming assignment is to determine whether a number is a perfect square. That only requires checking whether
ceil(sqrt(x))**2 = x
This is much easier than determining whether a number is perfect, which is an abstract property in number theory.
Okay. I don't know if your class discussed PROC FCMP, which enables you to define DATA step functions. If so, I recommend that you write an FCMP function that takes a number and computes whether it is perfect by finding the sum of all integer divisors. A short intro to PROC FCMP is at "Extending SAS: How to define new functions in PROC FCMP."
@Sharatm9 wrote:
Thank you for response, Sir. But the question is correct. It requires us to get first N (6) perfect numbers. (where the divisors adds upto to the number. the quoted example is 28[1,2,4,7,14])
Finding the first 6 of just about anything is likely to be much easier than an arbitrary N as indicated in your first post. So which is it, first 6 or first N?
It the first 6.
Given the limitations of SAS, only the first 7 perfect numbers can be calculated with numeric variables anyway (see https://en.wikipedia.org/wiki/Perfect_number and the continuing link https://oeis.org/A000396).
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.