DATA Step, Macro, Functions and more

ERROR in Input

Accepted Solution Solved
Reply
Contributor
Posts: 72
Accepted Solution

ERROR in Input

[ Edited ]

Here is my wildcard code:

 


data details_FEB;
infile "/v_share/Xiaomin/SCOPES/sas_dataset/Oct-08-2015/ScopesCalculations_SecondaryConstruction_*" linesize = 300 firstobs = 2;

 

input
C_ST $3.0
C_DSTRB_AREA $5.0
N_RSK $5.0

IsRevision9 $1.0
ScheduleNumberException $2.0
IsAsgrReportExists $2.0

ConstructionClass 1.0
COT00503.C_CSP_CONST_CLS 1.0

ERROR: DATA STEP Component Object failure. Aborted during the COMPILATION phase.
ERROR 557-185: Variable COT00503 is not an object.
COT00503.F_CSP_CONST_CLS 1.0
CombustibilityClass 1.0
COT00503.C_COMB_CLS 1.0
COT00503.F_COMB_CLS 1.0
COT00503.N_STOR 1.0
PartialSprinklerCreditFactor 1.0
LimitedSupplyCreditFactor 1.0
COT00503.C_SPK $1.0
SprinklerCreditType $1.0
COT00512.C_IPM $1.0
InternalProtectionMethod $1.0
TotalFloorArea 6.0
COT00504.R_TL_FLR_AREA 6.0
TotalRoofArea 6.0
COT00504.R_TL_RF_AREA 6.0
TotalSpecificFloorArea 6.0
COT00504.R_TL_SPEC_FLR 6.0
TotalFloorAndRoofArea 6.0
COT00520.C_SEC_CONST $1.0
COT00511.N_BGN_LVL 1.0
COT00511.N_THRU_LVL 1.0
COT00511.C_VO_PROT $1.0
COT00515.N_SCHD 15.0
FloorLevel 1.0
COT00516.N_LEN*COT00516.N_WDTH 6.0
COT00516.C_LVL_TYP $10.0
IsLowestFloor $10.0
COT00511.F_DIV_WL $10.0
COT00516.F_OTH $10.0
COT00516.C_AS_TYP $10.0
COT00520.N_SQFT $10.0
COT00520.C_RF_SRFC $10.0
COT00520.F_COMB_SB $10.0
COT00520.F_FOAM_PLSTC $10.0
COT00520.F_ACPT_TB $10.0
COT00520.R_PCT_STOR_AFCT $10.0
COT00520.R_PCT_OTH_FLR 3.0
COT00520.C_BLDG_COND $5.0
Percentage $5.0
COT00520.R_PCT_OTH_FLR $5.0
EffectiveArea $5.0
COT00520.R_TL_FLR_AREA $5.0
Charge $5.0
COT00520.R_CHRG $5.0
COT00520.F_CHRG $5.0
SecondaryConstructionCharge $5.0
COT00520.R_TL_SEC_CONST $5.0;
run;

 

Could you please help?


Accepted Solutions
Solution
‎02-09-2016 04:06 PM
Super User
Posts: 17,784

Re: ERROR in Input

data details_FEB;
 
infile "/v_share/Xiaomin/SCOPES/sas_dataset/Oct-08-2015/ScopesCalculations_SecondaryConstruction_Sample1.csv" linesize = 300 firstobs = 2 DSD Truncover ;

Informat 
C_ST $2
C_DSTRB_AREA $4
N_RSK $6
COT00503D_SRVY $6;


input
C_ST $
C_DSTRB_AREA $
N_RSK $
COT00503D_SRVY $;

Try the following. 

Point to a specific file, don't use the wildcard until you have it working. 

Since file is csv add DSD option. 

Add Truncover option to allow SAS to ignore extra variables at this point. 

View solution in original post


All Replies
Super User
Posts: 5,079

Re: ERROR in Input

In SAS, a dot is not a valid character for naming a variable.  You're limited to underscores, letters, and numbers.

 

Yes, there are special steps you can take to change that ... but that's not the default.

Contributor
Posts: 72

Re: ERROR in Input

I see. Could you please advise how to "rename" or fix the variable name? (doing this manually is a very time consuming task). Thank you
Super User
Posts: 17,784

Re: ERROR in Input

Fix your input first!!!!!!!!!!

All these other errors, inconsistent types, invalid variable names will go away if the data is imported correctly and consistently. 

Post sample data now. 

Contributor
Posts: 72

Re: ERROR in Input

Here is a sample of my data. Thank you for help

Super User
Posts: 17,784

Re: ERROR in Input

Do you have a data dictionary for the data?
Otherwise you sadly have the task of identifying and confirming each variable type/format. 

Contributor
Posts: 72

Re: ERROR in Input

Fortunately, I do have a data dictionary indicating the type and bytes for each variable.

Fixing this for all the variables is going to fix the issue?,
Super User
Posts: 17,784

Re: ERROR in Input

Most of them, others will probably pop up Smiley Happy

Can you provide your data dictionary?

 

Contributor
Posts: 72

Re: ERROR in Input

Example:

C_ST CHAR(2)
C_DSTRB_AREA CHAR(4)
N_RSK DECIMAL(6,0)
COT00503D_SRVY CHAR(6)


Contributor
Posts: 72

Re: ERROR in Input

I think there is a bigger issue here:

 

I considered only couple of first variables with the correct format/type. Then I ran the program but as you see in the picture below, the vaules in the columns are mis-placed!!   

 

forexample, the last column does not include any "date" !!

 

why?


1.jpg
Super User
Posts: 17,784

Re: ERROR in Input

Your still not reading it correctly.

 

How are you specifying the type, what does your code look like?

 

Here's the documentation regarding how to input files. Skip the first part and go down to the examples and see how they're importing data and how you need to specify your fields.

 

http://support.sas.com/documentation/cdl/en/lestmtsref/63323/HTML/default/viewer.htm#n1rill4udj0tfun...

Contributor
Posts: 72

Re: ERROR in Input

Here is the code (considering the first four variables, knowing that they are all character and having those numbers of byets):

 

data details_FEB;

 

infile "/v_share/Xiaomin/SCOPES/sas_dataset/Oct-08-2015/ScopesCalculations_SecondaryConstruction_*" linesize = 300 firstobs = 2;

 

input
@1 C_ST $2.0
@2 C_DSTRB_AREA $4.0
@3 N_RSK $6.0
@4 COT00503D_SRVY $6.0;

run;

Solution
‎02-09-2016 04:06 PM
Super User
Posts: 17,784

Re: ERROR in Input

data details_FEB;
 
infile "/v_share/Xiaomin/SCOPES/sas_dataset/Oct-08-2015/ScopesCalculations_SecondaryConstruction_Sample1.csv" linesize = 300 firstobs = 2 DSD Truncover ;

Informat 
C_ST $2
C_DSTRB_AREA $4
N_RSK $6
COT00503D_SRVY $6;


input
C_ST $
C_DSTRB_AREA $
N_RSK $
COT00503D_SRVY $;

Try the following. 

Point to a specific file, don't use the wildcard until you have it working. 

Since file is csv add DSD option. 

Add Truncover option to allow SAS to ignore extra variables at this point. 

Contributor
Posts: 72

Re: ERROR in Input

I got the result for one file using the code below (a minor change for the last variable):

 

 

 

data details_FEB;

infile "/v_share/Xiaomin/SCOPES/sas_dataset/Oct-08-2015/ScopesCalculations_SecondaryConstruction_ 64_10122015_2339.csv" linesize = 300 firstobs = 2 DSD Truncover ;

 

Informat
C_ST $2.0
C_DSTRB_AREA $4.0
N_RSK $6.0
COT00503D_SRVY $10.0;


input
C_ST $
C_DSTRB_AREA $
N_RSK $
COT00503D_SRVY $;

run;

 

 

I got the result and looks good. But the last variable needs to be "date". I tried "MMDDYY10." for Informat but it did not work. please advise what to use for both informat and input.

Super User
Posts: 17,784

Re: ERROR in Input

Given your sample information, this would be closer to what you might actually need, note the informat and format for the date variable.

 

 

Informat 
C_ST $2
C_DSTRB_AREA $4
N_RSK $6
COT00503D_SRVY ddmmyy10.;
format COT00503D_SRVY date9.; input C_ST $ C_DSTRB_AREA $ N_RSK $ COT00503D_SRVY ;

 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 28 replies
  • 585 views
  • 0 likes
  • 4 in conversation