Advertisement

06.28.2007 at 03:15PM PDT, ID: 22665590
[x]
Attachment Details

SAS or Teradata SQL problem: adding columns with 1 or 0 values

Asked by Elmo_Yang in SQLBase, SQL Query Syntax, SAS

Tags: sas, teradata, sql

I have a table as follows:
ID               Code
A01           111
A02           112
A03           112
A04           113
A05           114
A06           114
All the code are in the range between 111 and 180 with different frequencies of occurrence.
I want to create columns that contain indicators of these codes. The table I want after adding these indicators is as follows:
ID               Code        Code_111      Code_112      Code_113           Code_114
A01           111            1                   0                    0                          0
A02           112            0                   1                    0                          0
A03           112            0                   1                    0                          0
A04           113            0                   0                    1                          0
A05           114            0                   0                    0                          1
A06           114            0                   0                    0                          1

Since there're 70 code numbers, it's simply too hard to do this manually. Is there a way that I can do this quickly in SAS or Teradata like a macro? Thanks a lot for your help in advance.

Start Free Trial
[+][-]06.28.2007 at 04:01PM PDT, ID: 19385531

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.28.2007 at 04:08PM PDT, ID: 19385559

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: SQLBase, SQL Query Syntax, SAS
Tags: sas, teradata, sql
Sign Up Now!
Solution Provided By: sasmeister
Participating Experts: 2
Solution Grade: A
 
 
[+][-]06.28.2007 at 07:22PM PDT, ID: 19386171

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.02.2007 at 01:00PM PDT, ID: 19406492

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32