Type : CREATION_INTERNE
Examples use generated data (datalines) or SASHELP.
| 1 | DATA mydata; |
| 2 | INPUT ssn $ city $ state $; |
| 3 | DATALINES; |
| 4 | 123-45-6789 Raleigh NC |
| 5 | 987-65-4321 Cary NC |
| 6 | 111-22-3333 Apex NC |
| 7 | 444-55-6666 Durham NC |
| 8 | 123-45-6789 Raleigh NC |
| 9 | . missing_city missing_state |
| 10 | ; |
| 11 | RUN; |
| 12 | |
| 13 | DATA new(index=(ssn)); |
| 14 | SET mydata; |
| 15 | RUN; |
| 1 | DATA mydata; |
| 2 | INPUT ssn $ city $ state $; |
| 3 | DATALINES; |
| 4 | 123-45-6789 Raleigh NC |
| 5 | 987-65-4321 Cary NC |
| 6 | 111-22-3333 Apex NC |
| 7 | 444-55-6666 Durham NC |
| 8 | 123-45-6789 Raleigh NC |
| 9 | . missing_city missing_state |
| 10 | ; |
| 11 | RUN; |
| 12 | |
| 13 | DATA new(index=(cityst=(city state))); |
| 14 | SET mydata; |
| 15 | RUN; |
| 1 | DATA mydata; |
| 2 | INPUT ssn $ city $ state $; |
| 3 | DATALINES; |
| 4 | 123-45-6789 Raleigh NC |
| 5 | 987-65-4321 Cary NC |
| 6 | 111-22-3333 Apex NC |
| 7 | 444-55-6666 Durham NC |
| 8 | 123-45-6789 Raleigh NC |
| 9 | . missing_city missing_state |
| 10 | ; |
| 11 | RUN; |
| 12 | |
| 13 | DATA new(index=(ssn cityst=(city state))); |
| 14 | SET mydata; |
| 15 | RUN; |
| 1 | DATA mydata; |
| 2 | INPUT ssn $ city $ state $; |
| 3 | DATALINES; |
| 4 | 123-45-6789 Raleigh NC |
| 5 | 987-65-4321 Cary NC |
| 6 | 111-22-3333 Apex NC |
| 7 | 444-55-6666 Durham NC |
| 8 | ; |
| 9 | RUN; |
| 10 | |
| 11 | /* This will fail if there are duplicates in ssn (like '123-45-6789') */ |
| 12 | DATA new(index=(ssn /unique)); |
| 13 | SET mydata; |
| 14 | RUN; |
| 1 | DATA mydata; |
| 2 | INPUT ssn $ city $ state $; |
| 3 | DATALINES; |
| 4 | 123-45-6789 Raleigh NC |
| 5 | 987-65-4321 Cary NC |
| 6 | . missing_city missing_state |
| 7 | 111-22-3333 Apex NC |
| 8 | ; |
| 9 | RUN; |
| 10 | |
| 11 | DATA new(index=(ssn /nomiss)); |
| 12 | SET mydata; |
| 13 | RUN; |
| 1 | DATA mydata; |
| 2 | INPUT ssn $ city $ state $; |
| 3 | DATALINES; |
| 4 | 123-45-6789 Raleigh NC |
| 5 | 987-65-4321 Cary NC |
| 6 | 111-22-3333 Apex NC |
| 7 | . missing_city missing_state |
| 8 | ; |
| 9 | RUN; |
| 10 | |
| 11 | DATA new(index=(ssn /unique/nomiss cityst=(city state) /unique/nomiss)); |
| 12 | SET mydata; |
| 13 | RUN; |