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
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: