BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
monsoon1
Calcite | Level 5

Hi everyone, Im a bit stuck on understanding this code. Can someone advise on what is the purpose of proc format cntlout, bold below

 

proc format cntlin=pg2.np_types_regions;
run;

proc format cntlout = typfmtout;
select $TypCode;
run;

data typfmt_update;
    set typfmtout pg2.np_newcodes;
    keep FmtName Start Label;
    FmtName='$TypCode';
run;

proc format cntlin= typfmt_update;
run;

title1 'Park Frequencies by Type';
proc freq data=pg2.np_summary;
    table Type / nocum;
    format Type $TypCode.;
run;
title;

Thanks

M

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Probably because it is taking the scenic route?

 

The first two steps can be reduced to one (or none if you just use WHERE= dataset option in third step).

data typfmt_update;
  set pg2.np_types_regions(where=(upcase(fmtname)='TYPCODE'))
      pg2.np_newcodes
  ;
  keep fmtname type start label;
  fmtname='TYPCODE';
  type='C';
run; 

Basically you are adding the observations from PG2.NP_NEWCODE to the set of values used to define $TYPCODE format.  So that the next step can use PROC FORMAT to actually create the format. Which is used by the final step to change how the values or TYPE are displayed (and hence how they are grouped by PROC FREQ).

 

View solution in original post

2 REPLIES 2
Kathryn_SAS
SAS Employee

The CNTLOUT= option on the PROC FORMAT statement creates an output data set with all the variables associated with the $Typcode format. You can view this data set by adding the following:

proc print data=typfmtout;

run;

Tom
Super User Tom
Super User

Probably because it is taking the scenic route?

 

The first two steps can be reduced to one (or none if you just use WHERE= dataset option in third step).

data typfmt_update;
  set pg2.np_types_regions(where=(upcase(fmtname)='TYPCODE'))
      pg2.np_newcodes
  ;
  keep fmtname type start label;
  fmtname='TYPCODE';
  type='C';
run; 

Basically you are adding the observations from PG2.NP_NEWCODE to the set of values used to define $TYPCODE format.  So that the next step can use PROC FORMAT to actually create the format. Which is used by the final step to change how the values or TYPE are displayed (and hence how they are grouped by PROC FREQ).

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

LIBNAME 101

Follow along as SAS technical trainer Dominique Weatherspoon expertly answers all your questions about SAS Libraries.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 897 views
  • 2 likes
  • 3 in conversation