data preparation

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

data preparation

I have

EXTERNALINTERNAL01INTERNAL02INTERNAL03INTERNAL04
1234
A* *
B** *
C **
D***

I want:

INTERNALEXTERNAL
1A
1B
1D
2B
2D
3A
3C
3D
4B
4C

pro

Any way to do this in SAS ? Thank you!


Accepted Solutions
Solution
‎08-24-2013 04:19 PM
Super User
Super User
Posts: 6,502

Re: data preparation

data want ;

  set have ;

  array x internal01-internal04 ;

  do internal=1 to dim(x);

    if x(internal)='*' then output;

  end;

  keep external internal;

run;

View solution in original post


All Replies
Respected Advisor
Posts: 4,663

Re: data preparation

What you have is a text file, an Excel worksheet or a SAS dataset? - PG

PG
Solution
‎08-24-2013 04:19 PM
Super User
Super User
Posts: 6,502

Re: data preparation

data want ;

  set have ;

  array x internal01-internal04 ;

  do internal=1 to dim(x);

    if x(internal)='*' then output;

  end;

  keep external internal;

run;

Trusted Advisor
Posts: 1,131

Re: data preparation

Tom's approach is much better than the below code.

However just thought to put my version of the code


data want(keep=external i value rename=(i=internal) where=(value ne ''));
    set have;
    array val(4) $     INTERNAL01-INTERNAL04;
    do i = 1 to 4;
    value=val(i);
    output;
    end;
    run;

proc sort data=want;
    by internal;
run;

Thanks,

Jagadish

Thanks,
Jag
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 200 views
  • 2 likes
  • 4 in conversation