Hello,
How to customize format of some variables when importing CSV file inside PROC IMPORT ? Appreciate for any help.
@Reeza wrote:
You cannot do that within PROC IMPORT.
However, once you run PROC IMPORT check your log, it will have the generated code including the types. Copy and paste that into your editor and then modify it as necessary.
If you're using traditional SAS (Display Manager) you can copy the code from the log without the line numbers by holding down ALT+SHIFT (I think) while selecting with the cursor. Or I strip the line numbers in NotePad++
Or, again in the Display manager enhanced editor, immediately after running the proc import press the F4 key. By default this is set to "recall" last code submitted into the editor. In this case, the "last code" is that generated by Proc Import. The result will be at the top of the editor window and will likely need to be moved in the program flow.
Proc Import can't guarantee weather a numeric variable will be assigned as a num type or char type. That is probably the reason it does not contain a format statement.
After importing the dataset you should check the variables weather they were assigned the right type. Then you can use proc datasets or a data step to assign the wanted formats.
Do not use PROC IMPORT, write the data step yourself. Or run IMPORT once, copy the data step from the log, and adapt it to your needs.
You cannot do that within PROC IMPORT.
However, once you run PROC IMPORT check your log, it will have the generated code including the types. Copy and paste that into your editor and then modify it as necessary.
If you're using traditional SAS (Display Manager) you can copy the code from the log without the line numbers by holding down ALT+SHIFT (I think) while selecting with the cursor. Or I strip the line numbers in NotePad++
@Reeza wrote:
You cannot do that within PROC IMPORT.
However, once you run PROC IMPORT check your log, it will have the generated code including the types. Copy and paste that into your editor and then modify it as necessary.
If you're using traditional SAS (Display Manager) you can copy the code from the log without the line numbers by holding down ALT+SHIFT (I think) while selecting with the cursor. Or I strip the line numbers in NotePad++
Or, again in the Display manager enhanced editor, immediately after running the proc import press the F4 key. By default this is set to "recall" last code submitted into the editor. In this case, the "last code" is that generated by Proc Import. The result will be at the top of the editor window and will likely need to be moved in the program flow.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.