sorry about my data
but why are you specifically doing for first 3 records and first 5 records
It not the first three (and five) records but, rather, the first three variables and the last five variables.
The code is changing the commas to semicolons for all fields except the fourth one, the one that can contain embedded commas.
Then it is simply reading the record, using semicolons as the delimiter and only expecting to possibly confront commas when reading the fourth field.
Thank you its gr8 function I ever came across thank you very much to learn about this
You may not have any control over the source of the CSV, but if you do and it comes out of Excel, you could request a tab delimited file as source instead. This is just as easy to produce from Excel, and can be read with the standard Proc Import in SAS. The advantages are: commas in the value are no longer a problem, no non standard code to maintain, and any additional columns which might be introduced into the data will be dealt with automatically.
I would also advocate use of the comma informat.
Richard
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.