So I used EG 6.1 (with local SAS 9.4) and ran a simple program step to make an example file with one numeric and one character variable.
I then used both the interactive export and the export as a step in project flow to export the data set as a CSV. The files were identical and both included the leading zeros. Plus when I did the conversion as a step in the process flow then Enterprise Guide let be browse the created CSV file so that I could confirm that the leading zeros where there.
I also tried just attaching the Z2. format to the numeric variable with a FORMAT statement in the step that made the data and that also generated leading zeros in the CSV file.
I suspect that something down stream from SAS is removing the leading zeros for you. For example if you double click on a CSV file and open it with Excel then Excel will convert anything that looks like a number to a number and leading zeros will be lost. If the goal is to use this data with Excel then export it to an XLS or XLSX file instead of a CSV file.
I think you need to review the information about SAS Variables. See SAS(R) 9.4 Language Reference: Concepts, Fourth Edition.
There are only two types of variables in SAS: numeric and character. The numeric variables are stored in 8 bytes of memory in Float-Point internal representation (Machine)
The format in SAS allows different ways to present or display in reports (human) the value stored in a numeric variable which includes dates, datetimes and times. The format does not change in any way the numeric variable.
Ctorres
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.