BookmarkSubscribeRSS Feed
7 REPLIES 7
Tom
Super User Tom
Super User

If you use a FORMAT like 20. in your INPUT statement

@43 Job_Title @ 20.

then SAS expects a variable name to precede the format.

 

Did you mean to read JOB_TITLE as a character variable? So perhaps you wanted.

68 @43 Job_Title $20.

 

 

 

ssv
Fluorite | Level 6 ssv
Fluorite | Level 6

Thank you so much Tom... I appreciate your help. By mistake i inserted @ instead of $.

Got the result now.

Thank you for your response. Have a Good one.

vipendra
Calcite | Level 5

Hi Tom,

 

Getting same error and tried your suggestion but still hut resolved. Please help me out.

Code to import the file:

 

data get_US_Company_Dataset;
infile 'C:\Users\HP\Desktop\Jigsaw_Acedemy\US_Company_Dataset.csv' dlm=',' dsd missover firstobs=1 lrecl=20;
input $company_name_id $10 $company_name year_founded $city $state $country zip_code $company_type $date_of_audit;
proc print;
run;

also not getting the output.

 

Regards

VIpendra

+919106739515

ErikLund_Jensen
Rhodochrosite | Level 12

Hi vipendra

 

You forgot a period after the character format. I often forget i too.

vipendra
Calcite | Level 5

Thanks for correcting me @ErikLund_Jensen 

Still some of error is throwing.

 

I want to connect with you personally to learn something from you.

Please mail me @ vipendratripathi6@gmail.com or whatsapp me @+919806980858.

 

Regards

Vipendra

Tom
Super User Tom
Super User

@vipendra wrote:

Hi Tom,

 

Getting same error and tried your suggestion but still hut resolved. Please help me out.

Code to import the file:

 

data get_US_Company_Dataset;
infile 'C:\Users\HP\Desktop\Jigsaw_Acedemy\US_Company_Dataset.csv' dlm=',' dsd missover firstobs=1 lrecl=20;
input $company_name_id $10 $company_name year_founded $city $state $country zip_code $company_type $date_of_audit;
proc print;
run;

also not getting the output.

 

Regards

VIpendra

...


You have way too many variables for the lines of data to only be 20 bytes long.  Remove the LRECL= option on the INFILE statement.

 

You have an extra $ in front of the variable COMPANY_NAME_ID.  Also why should that variable be only the single character in column 10 of the input data line?

 

You will have much better success if you first define the variables and then just list them in the INPUT statement. That way your INPUT statement does not need any formats or dollar signs.  For example just add a LENGTH statement and define which variables are numeric (length of 8 to store the full 8 byte floating point numbers that SAS uses for all numbers) and which are character (maximum length in bytes).

data get_US_Company_Dataset;
  infile 'C:\Users\HP\Desktop\Jigsaw_Acedemy\US_Company_Dataset.csv' dlm=',' dsd TRUNCOVER firstobs=1 ;
  length company_name_id $10 company_name $40 year_founded 8 
    city $30 state $15 country $20 zip_code $10 
    company_type $20 date_of_audit $10
  ;
  input company_name_id company_name year_founded city state country 
      zip_code company_type date_of_audit
  ;
run;
vipendra
Calcite | Level 5
Thanks Tom.

It works.

Reagrds
Vipendra

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!

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
  • 7 replies
  • 22641 views
  • 0 likes
  • 4 in conversation