BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
DrAbhijeetSafai
Lapis Lazuli | Level 10

I am able to create format from dataset with following simple step.

 

data fmt_cntlin;
     set codelist4 (keep= order term rename=(order=start term=label));
     fmtname = "myfmt";
run;

proc format cntlin = fmt_cntlin;
run;

 

Now, I am trying to create informat with similar method. Is it possible to do so with some minor modifications? Maybe some changes in cntlin option or addition of type = 'i' statement after fmtname statement etc.? 

 

Thanks in advance! 

 

- Dr. Abhijeet Safai

Dr. Abhijeet Safai
Certified Base and Clinical SAS Programmer
Associate Data Analyst
Actu-Real
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Yes. If you want make a NUMERIC type informat, you need add "type='I'" .

data fmt_cntlin;
     set sashelp.class( keep= name age rename=(name=start age=label));
     fmtname = "myfmt"; type='I';
run;

proc format cntlin = fmt_cntlin;
run;

data _null_;
 set sashelp.class;
 fmt=input(name,myfmt.);
 put name= age= fmt=;
run;

Ksharp_0-1709802901922.png

 

View solution in original post

4 REPLIES 4
DrAbhijeetSafai
Lapis Lazuli | Level 10

At the moment, it seems that I was able to solve this by using type = 'j' statement after fmtname statement. I will confirm it soon and will post a confirmed response here. 

 

Thank you.

 

- Dr. Abhijeet Safai

Dr. Abhijeet Safai
Certified Base and Clinical SAS Programmer
Associate Data Analyst
Actu-Real
Tom
Super User Tom
Super User

@DrAbhijeetSafai wrote:

At the moment, it seems that I was able to solve this by using type = 'j' statement after fmtname statement. I will confirm it soon and will post a confirmed response here. 

 

Thank you.

 

- Dr. Abhijeet Safai


When in doubt do a test.

Make a format (or informat) of the type you want using normal VALUE or INVALUE statement. Then use CNTLOUT= option to make a dataset of the format.  Then examine the dataset and see what variables are used and what values they have.

Ksharp
Super User

Yes. If you want make a NUMERIC type informat, you need add "type='I'" .

data fmt_cntlin;
     set sashelp.class( keep= name age rename=(name=start age=label));
     fmtname = "myfmt"; type='I';
run;

proc format cntlin = fmt_cntlin;
run;

data _null_;
 set sashelp.class;
 fmt=input(name,myfmt.);
 put name= age= fmt=;
run;

Ksharp_0-1709802901922.png

 

DrAbhijeetSafai
Lapis Lazuli | Level 10

@Ksharp , many thanks! 🙂

 

- Dr. Abhijeet Safai

Dr. Abhijeet Safai
Certified Base and Clinical SAS Programmer
Associate Data Analyst
Actu-Real

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 714 views
  • 2 likes
  • 3 in conversation