BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
fatemeh
Quartz | Level 8

Hello,

How to customize format of some variables when importing CSV file inside PROC IMPORT   ? Appreciate for any help.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@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.

View solution in original post

4 REPLIES 4
Shmuel
Garnet | Level 18

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. 

Reeza
Super User

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++

 

 

ballardw
Super User

@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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1041 views
  • 6 likes
  • 5 in conversation