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.
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:
infile "/folders/myfolders/Oct26/Runners.txt" ;
input amt 8.2;
The flat text file I wanted to read with the above code:
Part of SAS Log:
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 🙂
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 open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.