DATA Step, Macro, Functions and more

Rename Column and Results

Reply
Contributor
Posts: 26

Rename Column and Results

 I renamed  my columns from 01-12 to Jan-Dec but the PROC PRINT results does not align the results with the fields. 

[Note] the Results table list the months as 1-12 and not _01, _02, etc.  -But there are listed as numeric variables.

 

 

DATA RESULTS;

SET RESULTS;

JAN = _01;

FEB = _02;

MAR = _03;

APR = _04;

MAY = _05;

JUN = _06;

JUL = _07;

AUG = _08;

SEP = _09;

OCT = _10;

NOV = _11;

DEC = _12;

 

DATA LOADFAC DIVRSFAC;

SET RESULTS;

IF STATISTIC = 'LF' THEN OUTPUT LOADFAC; ELSE

IF STATISTIC = 'DF' THEN OUTPUT DIVRSFAC;

 

PROC PRINT DOUBLE DATA=DIVRSFAC;

VAR COSSNAME STATISTIC JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC;

FORMAT JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC ;

TITLE '2016 MONTHLY CLASS ';

TITLE2 'BASED ON SALES ';

 

PROC PRINT DOUBLE DATA=LOADFAC;

VAR COSSNAME STATISTIC JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC;

FORMAT JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC ;

TITLE '2016 MARYLAND MONTHLY ';

TITLE2 'BASED ON SALES';

run;

 

 

results.jpg

PROC Star
Posts: 7,356

Re: Rename Column and Results

Your code didn't rename variables but, rather, has improper code to establish new values for the variables JAN, FEB, etc.

 

I would have to guess that you log showed that the code didn't run or replace the file. Additionally, it doesn't look like you could have obtained the results you posted, since the file wasn't limited to either LF or DF. The only way it could list the numbers shown as variable names is if those were labels that were assigned to JAN, FEB, etc.

 

Art, CEO, AnalystFinder.com

Trusted Advisor
Posts: 1,604

Re: Rename Column and Results

Unless I'm doing something wrong, your results are too small for me to read or even see, so maybe I'm not clear on the actual problem you see.

 

In your first data step, you are NOT renaming the columns. You are assigning numbers to the variables JAN, FEB, etc.

 

Ask a Question
Discussion stats
  • 2 replies
  • 95 views
  • 1 like
  • 3 in conversation