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
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;
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
@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.
Not "j" but "I" works for informat. Many thanks @Ksharp !
I am replying to my own post for the purpose of documentation. What a wonderful feeling it is to find out your own post some months back and finding answer in it next time when you search about it on the google! 🙂
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 , many thanks! 🙂
- Dr. Abhijeet Safai
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!
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.