BookmarkSubscribeRSS Feed
Reeza
Super User

You  don't use infile for Excel files, proc import or lib name are better options.

Provide more details of your issues and better yet a sample file

Or save as CSV and then write infile statements.

5 REPLIES 5
Anotherdream
Quartz | Level 8

As reeza earlier pointed out, save the Excel file as a csv and then use an infile.

For excel you are stuck to proc import and/or libname statement. (unfortunately).

Note I imagine your values are getting truncated because Excel only uses the first 8 rows to determine variable type / length / etc.. Try adding the following options to your Proc Import and see if that fixes it.

guessingrows=X (i like 32000);  The x is the number of rows you want the system to check to determine the variable type / length.

rakeshvvv
Quartz | Level 8

I am using proc import and values are getting truncated at the N Column.......even though all decimals are not significant.....we would like to populate in the dataset the way it was collected.Attaching sample file.

Reeza
Super User

I only see one decimal place?

My guess is you just need to change the display format, the underlying data is fine.

Post a proc contents on your imported data set.

rakeshvvv
Quartz | Level 8

here is my proc content....

        Alphabetic List of Variables and Attributes

                              #Variable TypeLenFormat InformatLabel

                            
17COMMENT1 Char118$118.  $118.   COMMENT1
                              1SUBJIDN  Num   8BEST14.            SUBJIDN 
                              6VISITNUM Num   8BEST14.            VISITNUM
                              2XBCATN   Num   8BEST14.            XBCATN  
                              5XBNAM    Char 14$14.   $14.    XBNAM   
                             14XBORRES  Char 14$14.   $14.    XBORRES 
                             15XBORRESU Char 14$14.   $14.    XBORRESU
                             16XBREASNDNChar 14$14.   $14.    XBREASNDN
                              4XBREFID  Char 21$21.   $21.    XBREFID 
                              3XBSPECN  Num   8BEST14.            XBSPECN 
                             11XBTEST   Char 30$30.   $30.    XBTEST  
                             10XBTESTCD Char 16$16.   $16.    XBTESTCD
                             13XBTSTDL  Char 36$36.   $36.    XBTSTDL 
                             12XBTSTDLN Num   8BEST15.            XBTSTDLN
                              7XB_D     Num   8BEST14.            XB_D
                              8XB_M     Num   8BEST14.            XB_M
                              9XB_Y     Num   8BEST14.            XB_Y 
Reeza
Super User

XBorres which corresponds to N column was brought in as a character so that's your first problem.  If it has all the decimal places you can simply convert it to a numeric column using an input function.

Otherwise save as CSV and explicitly specify your type, though with that many digits you'll probably run into floating point errors anyways. 

You could bring it in as character all across if you really wanted to keep it though Excel will generate the same errors, it just doesn't warn/tell you about it.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

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.

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
  • 5 replies
  • 939 views
  • 0 likes
  • 3 in conversation