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

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
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
Pyrite | Level 9

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
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
Pyrite | Level 9

@Ksharp , many thanks! 🙂

 

- Dr. Abhijeet Safai

Dr. Abhijeet Safai
Associate Data Analyst
Actu-Real

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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