SAS with Memory

Source: Internet
Author: User

Recently, the SAS code of the old system in the calculation process, there are less data, I passed a few times to check the code, or did not find the problem.

Finally, with the help of a senior colleague, I found the cause of the problem, but in retrospect I still feel that I am not careful enough and how to debug the SAS code is not proficient, description as follows:

The code is mainly the following code (the sensitive place will be omitted):


Data test.top_order_merge2;

Merge

Source.order_sub_1 (In=a)

Source.order2 (in=b keep=col1 col2 col3 col4 the COL5 state col6); /* Here the other fields are changed to col prefix, mainly state)

by Col1 Col2;

If A and B;

Run


This is the code, and the intent of the merge is that a indicates from order_sub_1,b that the expression comes from order2.

Keep means to keep those fields in Order2, but I thought of state as status.

When two tables have the value of a duplicate field, the value of the next table overwrites the value in the previous sheet.


Because the state as a status, so the latter became a directional thinking, wishful thought that the value of the Top_order_merge2 table is from the Order2 tables of the value of the State column.

Because there are only 5 valid state values in the Order2, the state in Order_sub_1 has 10 valid status values. In fact, there are 10 state values, and I think it is 5 state values (so it does not lose records), but the actual situation is that in subsequent checks, naturally will be filtered out part of the state of the record.

The resulting data is not present in the result set.

Later, through other colleagues to help, a step-by-step run and generate a result set check, only to find the state from the value of the state order_sub_1, and subsequent SAS in the judge condition is according to Order2 state value to judge, naturally there will be omission.


From this thing to sum up:

First: The SAS check code differs from the development language check. is to run each SQL step by step to see the result set

Second: The degree of carefulness needs to be improved, don't take it for granted

Third: The state value capture is not comprehensive

Four: The SAS grammar proficiency is not enough, because it is not often used, sometimes at intervals to use, and this time is easy to forget.

More attention will be paid to this situation in the future to avoid recurrence.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.