Hi.
I have a problem on creation user defined formats.
So, I try to create my own formats by using my dataset and want to add to the last row the "Not Found" values, but my code deletes the last rows and adds the "Not Found" statement.
Please give me a hint. the code is below;
data control_format /view=control_format;
set cuserv.ABC_General (drop=Quantity Retail_Price
rename=(N_Item_Name = Start
Class = Label))
end = last;
retain fmtname '$mdclass'
Type 'C';
if last then do;
Start = ' ';
HLO = 'O';
Label = 'Not Found';
end;
run;
proc format cntlin=control_format fmtlib;
run;
If that's the only roadblock, it's easy to overcome. Add an OUTPUT statement in two places:
data control_format /view=control_format;
set cuserv.ABC_General (drop=Quantity Retail_Price
rename=(N_Item_Name = Start
Class = Label))
end = last;
retain fmtname '$mdclass'
Type 'C';
output;
if last then do;
Start = ' ';
HLO = 'O';
Label = 'Not Found';
output;
end;
run;
proc format cntlin=control_format fmtlib;
run;
You just need to control the output statement in the datastep (which is at the end by default):
data control_format;
set cuserv.abc_general (drop=quantity retail_price rename=(n_item_name=start)) end=last;
retain fmtname '$mdclass' type 'C';
if last then do;
output;
start=' ';
hlo='o';
label='not found';
output;
end;
else output;
run;
Hi.
I have a problem on creation user defined formats.
So, I try to create my own formats by using my dataset and want to add to the last row the "Not Found" values, but my code deletes the last rows and adds the "Not Found" statement.
Please give me a hint. the code is below;
data control_format /view=control_format;
set cuserv.ABC_General (drop=Quantity Retail_Price
rename=(N_Item_Name = Start
Class = Label))
end = last;
retain fmtname '$mdclass'
Type 'C';
if last then do;
Start = ' ';
HLO = 'O';
Label = 'Not Found';
end;
run;
proc format cntlin=control_format fmtlib;
run;
If that's the only roadblock, it's easy to overcome. Add an OUTPUT statement in two places:
data control_format /view=control_format;
set cuserv.ABC_General (drop=Quantity Retail_Price
rename=(N_Item_Name = Start
Class = Label))
end = last;
retain fmtname '$mdclass'
Type 'C';
output;
if last then do;
Start = ' ';
HLO = 'O';
Label = 'Not Found';
output;
end;
run;
proc format cntlin=control_format fmtlib;
run;
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!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.