I have a SAS code that needs to validate a price date field lesser than the system's current date, I would like to take experts suggestions on how to proceed with. The following is what I have planned to do with, but again I need to know how can I display the CUR_DT value..please help
CURDT = TODAY();
IF PRC_DTE <= CUR_DT
SAS has only two kinds of data: numbers and character strings.
For reporting/display purposes, SAS has a number of formats that can be used to display what you want.
Dates are simply numbers that represent the number of days since January 1, 1960 (0). To display a date, you use a format, such as mmddyy. or yymmdd. or date. (the period a the end of the identifier defines the identifier as a format, and so is required syntax).
It looks like you have done no reading of SAS documentation, and have received no training in SAS programming. This will make your life kinda difficult, as SAS is not an ordinary programming language, like C, Java, Pascal, etc.
Your code mixes the use of macro functionality with datastep code incorrectly.
And from the looks of your English, it looks like you will have difficulty understanding the documentation anyway.
So, we will need more information to really help you.
I didn't observe that my text got missed at the end, sorry for that. I was able to complete my task using the INTNX function. Like you said, I haven't trained on SAS I code on what exists on the system already.
Thanks for your clue and comments.
I have a different query now, can we able to validate LOW-VALUES for a field on input file.
The SAS documentation is available on-line, off the web.
It's a little hard to find, but once you are there, it's a wealth of information.
I would highly recommend that you beginning reading it, as soon and as much as possible.
SAS is not a process and control centric language, it is a data centric language. It was meant to simplify the programming efforts for people who data analysis.
The basic structure is called a DATA step.
The data step assumes that you are going to be looping through a file of "observations" (records, table rows, whatever) and doing something with the data. The name of a data step -- indata in my clue -- identifies the name of the output data set (a normal SAS binary data file). "INFILE" + "INPUT" reads data from an external data source (generally a flat file), "SET" reads data from a SAS data set. Then you simply write the code for what you want to do with that observation, and normally terminate the DATA step with "run;"
SAS is not an interpreted language, it is one of the first just-in-time compiled languages. It reads a block of code, compiles it, executes it, reads the next block of code, compiles it, executes it, etc. So, SAS is very efficient at processing large datasets, and the code is generally easy to read and maintain, given reasonable coding practices.
If you saw in my clue, that I did variable assignments after inputing the data, similarly you can do testing.
SAS supports all the normal looping control and decision structures for data.
if then else
The "for" loop is actually done with "do something=start to finish by interval"
SAS also has a very powerful case statement structure:
Select ( )
It would probably help you most to take the time now to find the online documentation and do more reading.
And then, create a directory/folder somewhere where you can "play".
In my environment, I do exactly that. I have a "play" directory where I experiment with SAS code as an intial development. It provides a place to learn what happens. After I have a start, then I move, or create something new from scratch, to/in our actual developement environment that will be moved through change management processes into production.
Thank you so much for the elobarate desciption about the SAS and take your advise with immediate effect.
I found that you have answered YES for my question of LOW-VALUES. Can you give a sample how to handle low-values of a field on input file. My requirement is to validate the field for low-values and to move spaces to them.
Assume there's a field on input file declared "A" and it has declared Char009. I need to check if the input has low values if so I need to change them to spaces before I write to the output file.
Please correct me if any mistakes and let me know if my requirment is not so clear.
I have found a way to handle the low values from a database. Using the RANK function.
IF RANK(database variable) NOT IN (0,255)
database variable = ' '; /* Move spaces to the variable */
This given me the required result.