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

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
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

28 REPLIES 28
Astounding
PROC Star

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.

almmotamedi
Obsidian | Level 7
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
Reeza
Super User

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. 

almmotamedi
Obsidian | Level 7

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

Reeza
Super User

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

almmotamedi
Obsidian | Level 7
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?,
Reeza
Super User

Most of them, others will probably pop up 🙂

Can you provide your data dictionary?

 

almmotamedi
Obsidian | Level 7
Example:

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


almmotamedi
Obsidian | Level 7

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
Reeza
Super User

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

almmotamedi
Obsidian | Level 7

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;

Reeza
Super User
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. 

almmotamedi
Obsidian | Level 7

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.

Reeza
Super User

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 ;

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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