data format;
input id weight date1 ddmmyy8.;
format id dollar8.2 weight comma10. date1 ddmmyy8.;
datalines;
189 1450 30-12-16
249 1679 30-12-16
3456 1958 30-12-16
5454 2205 30-12-16
;
proc print;
run;
informat id comma10.;
put id;
proc print;
run;
I wrote the above program after reading some info about the Informat but like it says in the text, informat statement is not removing the dollar sign ($) and period(.) and I'm getting same output in both the print procedures. Please let me know where I'm doing this wrong. Thank you:)
use format not informat
data format;
input id weight date1 ddmmyy8.;
format id dollar8.2 weight comma10. date1 ddmmyy8.;
datalines;
189 1450 30-12-16
249 1679 30-12-16
3456 1958 30-12-16
5454 2205 30-12-16
;
proc print data=format;
format id comma10.;
run;
proc contents data=format;
run;
Obs | id | weight | date1 |
---|---|---|---|
1 | 189 | 1,450 | 30/12/16 |
2 | 249 | 1,679 | 30/12/16 |
3 | 3,456 | 1,958 | 30/12/16 |
4 | 5,454 | 2,205 | 30/12/16 |
Maxim 2: Read the Log.
informat and put are data step statements and cannot be used outside of a data step.
I do not see any dollar signs or periods in your datalines that need to be removed.
"ID" values are (usually) not used in calculations and should therefore be stored as character. Why do you store them as numbers and assign a dollar display format?
Formats convert values to text. They are used when displaying the data. In code you can use them in PUT statement or PUT() function.
Informats convert text into values. They are only used when reading text. So they are used by INPUT statement or INPUT() function.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.