Desktop productivity for business analysts and programmers

REPORTING

Reply
Contributor
Posts: 28

REPORTING

HI All,

I have a dataset like

STATE_CDOEL1_NAMEL2_NAMEL3_NAME
RJAJMERPATNA

Now I want to Export this dataset in Excel like below.

Header 1Header 2
STATE_CODERJ
L1_NAMEAJMER
L2_NAMEPATNA
L3_NAME

Can any one of you help me on this .

Thanks In advance.

Super Contributor
Posts: 296

Re: REPORTING

You could do it with the TRANSPOSE Procedure:

PROC TRANSPOSE DATA=HAVE OUT=WANT (RENAME =(_NAME_  = 'HEADER 1'N COL1 = 'HEADER 2'N));

VAR STATE_CODE--L3_NAME;

RUN;

You could do it with a do loop as follows.

DATA WANT;

  SET HAVE;

  ARRAY C_VARS STATE_CODE--L3_NAME;

  DO I = 1 TO HBOUND(C_VARS);

  'HEADER 1'N = VNAME(C_VARS{I});

  'HEADER 2'N = C_VARS{I};

  OUTPUT;

  END;

  KEEP 'HEADER 1'N 'HEADER 2'N;

RUN;

Contributor
Posts: 28

Re: REPORTING

Thnaks a lot.

Its working

Trusted Advisor
Posts: 1,056

Re: REPORTING

You can also use the DATA | TRANSPOSE task if you want to use the EG point and click functionality.

Tom

Ask a Question
Discussion stats
  • 3 replies
  • 277 views
  • 0 likes
  • 3 in conversation