Friday, September 4, 2009

create a key for a dataset (1)

I am thinking to post idea about sas programming and predictive modeling. I will discuss problems arising from working environment. Some of them can be very elementary and some of them can be very advanced. I am thinking to put a number (from 1 to 5) in title to show how easy (1) or how difficult (5) the problem is. The mission is to disclose valuable experience to the public.
I will first post a problem and then wait for several days to post an answer or comments.





Problem:
A sas dataset does not have a key. How to create one ( i.e., how to create a new column to be used as key )?

Thursday, September 3, 2009

sas macro usage (1)

Problem:
For the following macro, which usage(s) are correct?
%macro add_xsh(a, b=10);
%global result;
%let result=%sysevalf(&a+&b);
&result
%mend add_xsh ;

  1. %let c=%add_xsh(3, b=20);
  2. %let c=%add_xsh(3, 20);
  3. %let c=%add_xsh(3);

Wednesday, September 2, 2009

adding records between sas dataset records (3)

Problem:
The original sas dataset is as follows.

v
1
1
1
2
2
3
3
3
3
v is an avariable name. We need to write codes to insert a record 0 between 1 and 2, and between 2 and 3, i.e., to produce a new sas dataset as follows.

v
1
1
1
0
2
2
0
3
3
3
3

First not the last

I am thinking to post idea about sas programming and predictive modeling. I will discuss problems arising from working environment. Some of them can be very elementary and some of them can be very advanced. I am thinking to put a number (from 1 to 5) in title to show how easy (1) or how difficult (5) the problem is. The mission is to disclose valuable experience to the public.

I will first post a problem and then wait for several days to post an answer or comments.