Hi All,
I have a table properties as below in which i want to keep label name same as column name
Please help me on this
Thanks,
Harsh
Then remove all the label from table .
data have;
set sashelp.class;
run;
proc datasets library=work nolist nodetails;
modify have;
attrib _all_ label=' ';
quit;
Why not just delete all labels then ?
Thanks,
But if i am generating proc report then it is taking label instead of columns so what to do in this case,
my code is as below:
proc report data=test;
column idd description &names;
define idd/'id';
define description/'desc';
&defines;
run;
Then remove all the label from table .
data have;
set sashelp.class;
run;
proc datasets library=work nolist nodetails;
modify have;
attrib _all_ label=' ';
quit;
Transpose to a long dataset layout, and use _NAME_ as ACROSS variable in PROC REPORT.
See Maxim 19 and Maxim 33.
PS still better:
Convert _LABEL_ to a SAS date value (INPUT with YYMMN6.), use that as ACROSS, with a format to your liking.
With dictionary tables and call execute it's quite simply:
data HAVE;
attrib AUG12 label='201208' length=8
SEP12 label='201209' length=8
OCT12 label='201210' length=8
NOV12 label='201211' length=8
DEC12 label='201212' length=8
JAN13 label='201301' length=8
FEB13 label='201302' length=8
MAR13 label='201303' length=8
APR13 label='201304' length=8
MAY13 label='201305' length=8
JUN13 label='201306' length=8
JUL13 label='201307' length=8
AUG13 label='201308' length=8 ;
run;
proc sql;
create table Have_Cols as
select memname,
name,
label
from dictionary.columns
where memname = 'HAVE'
;
quit;
data _null_;
set Have_cols end=EOF;
if _N_ = 1 then call execute ('data Have2; set Have;');
call execute ('Attrib '||name||' label="'||name||' ');
if EOF then call execute('; run;');
run;
A simple example:
data wide;
input id $ aug12 sep12 oct12;
label
aug12 = "201208"
sep12 = "201209"
oct12 = "201210"
;
datalines;
A 1 2 3
;
proc transpose data=wide out=trans (rename=(col1=value));
by id;
var aug12--oct12;
run;
data long;
set trans;
period = input(_label_,yymmn6.);
format period monyy5.;
drop _name_ _label_;
run;
With this vastly improved dataset layout, the code is now very simple:
proc report data=long;
column id value,period;
define id / group;
define value / "" analysis;
define period / "" across order=data;
run;
Result:
id AUG12 SEP12 OCT12 A 1 2 3
By changing the format for the ACROSS variable in PROC REPORT, you can get anything you like, without having to resort to macro programming or CALL EXECUTE steps.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.