Hi:
As I explained, I use $VARYING for "screen scraping" or grabbing lines of text, as when someone sends me a mainframe report file, and I have to "scrape" data out of the mainframe report. Then I use $VARYING to read one entire line, numbers, letters, punctuation, and spaces and then, I typically with use SUBSTR or SCAN to break the big text string into smaller character and numeric chunks.
I suspect you are not using screen scraping or text scraping, since you have numeric values. I cannot comment on whether TRUNCOVER would be required until you show your data. It really, really depends on what your data looks like. Is it fixed format? Is it delimited by some character? Are the numbers in "standard" numeric format or do your numbers have currency symbols and thousands separators, like commas? Consider these examples below. I would only use $VARYING. for the report, on the right. I would use standard INFILE and INPUT the other examples on the left.
Cynthia
I was using a variable length, only numeric data file. Below is how I tried - initially, before reading this thread - to read the file into SAS.
Code I used:
data test;
infile "/folders/myfolders/Oct26/Runners.txt" ;
input amt 8.2;
run;
proc print;
run;
The flat text file I wanted to read with the above code:
12345678.90
12500.02
5.11
Output:
123456.78 |
12500.02 |
Part of SAS Log:
123456.78 |
12500.02 |
5.11 |
So, I was wondering if there was an equivalent of $varying informat for reading numeric data :). Just curiousity 🙂
But, thanks for the very informative explanation as always 🙂
Thanks,
Abi
No need for either in that case. If you either remove the INFORMAT specification from the INPUT statement or add the colon modifier in front of it then you are using list mode input style and SAS will automatically read the next word in the file.
Also note that you do NOT want to include a decimal part on your informat specification, unless you need to tell SAS where to place implied decimal point for source text that has been generated without them. If you read the string '12345' with the 8.2 informat SAS will place the implied decimal point between the 3 and the 4 and the result will be 123.45 instead of 12,345.
For normal input there is no need for ANY informat specifications. SAS already knows how to read numbers and character strings without an special instructions. It is only things like dates and time where SAS needs help in understanding how to translate the human readable text into the internal value that it should store.
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.