Help using Base SAS procedures

date format required in YYYYMMDD

Reply
N/A
Posts: 0

date format required in YYYYMMDD

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();
CALL SYMPUT('CUR_DT',CURDT);
IF PRC_DTE <= CUR_DT
THEN
OUTPUT;
ELSE
DELETE;

Thank you,
N/A
Posts: 0

Re: date format required in YYYYMMDD

Boy are you confused.

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.

Here's a clue:
[pre]
data indata;
infile datalines;
input in_date anydtdte10.;
date1 = in_date;
date2 = in_date;
date3 = in_date;
return;
datalines;
26may2008
27may2008
12/25/2007
;
run;

proc print uniform;
format date1 date9. date2 mmddyy9. date3 yymmdd10.;
run;
quit;
[/pre]
the output is
[pre]
Obs in_date date1 date2 date3

1 17678 26MAY2008 05/26/08 2008-05-26
2 17679 27MAY2008 05/27/08 2008-05-27
3 17525 25DEC2007 12/25/07 2007-12-25
[/pre]
N/A
Posts: 0

Re: date format required in YYYYMMDD

Chunk,
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.

I am just a begineer!
N/A
Posts: 0

Re: date format required in YYYYMMDD

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.

Yes.

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
do while
do until
The "for" loop is actually done with "do something=start to finish by interval"
SAS also has a very powerful case statement structure:
Select ( )
when
otherwise

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.
N/A
Posts: 0

Re: date format required in YYYYMMDD

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.
Thank you,
N/A
Posts: 0

Re: date format required in YYYYMMDD

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)
THEN
DO;
OUTPUT FILE2;
END;
ELSE
DO;
database variable = ' '; /* Move spaces to the variable */
OUTPUT FILE2;
END;
This given me the required result.
N/A
Posts: 0

Re: date format required in YYYYMMDD

I got the answer to this using PUT(INTNX('DAY',DATE(),0,YYMMDD10.)); function.

Thanks for taking a look at my query.
Ask a Question
Discussion stats
  • 6 replies
  • 228 views
  • 0 likes
  • 1 in conversation