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

I have run the following code in order to import a .csv file of data (published by Statistics Canada) into a SAS dataset:

 

DATA WORK.Firm_count_Dec_2015;
format Ref_Date $7. GEO $12. 'Geographical Classification'n $2. SIZE $2. Description $24. Vector $9. Coordinate $8. Value 6.;
infile "c:\user\homareau\PredictiveModels\FirmCounts\Firm_count_Dec_2015.csv" firstobs=2 dlm=',' Missover DSD;
informat Ref_Date $7. GEO $12. 'Geographical Classification'n $2. SIZE $2. Description $24. Vector $9. Coordinate $8. Value 6.;
input Ref_Date $7. GEO $12. 'Geographical Classification'n $2. SIZE Description Vector Coordinate Value;
label Ref_Date = 'Date'
GEO = 'Prov_Name'
'Geographical Classification'n = 'Prov_Code'
SIZE = 'Firm_Size'
Description = 'NAICS_Description'
Vector = 'CANSIM_V_Code'
Coordinate = 'Coordinate'
Value = 'Count';
drop Vector Coordinate;
run;

 

However the data from the .csv file are not importing properly.  The attachment shows the end result.  It has to do with the delimiter but I thought my code was correct.  What am I missing?

 

Thanks...

 

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

Using Formatted Input with a delimited file is not compatable and will not give correct result.

 

input Ref_Date $7. GEO $12. 'Geographical Classification'n $2. SIZE Description Vector Coordinate Value;

Remove those INFORMAT specifications from the INPUT statement.  

 

Delimited files use LIST input.

View solution in original post

5 REPLIES 5
Cynthia_sas
SAS Super FREQ
Hi, it would be very helpful to know whether you got errors in the log or to see a small sample of the CSV file.
cynthia
ballardw
Super User

Please describe what is "wrong". Also, at least on my monitor you screen capture is too fuzzy to read.

It may help to post some lines of raw data and print results.

Jack1
Obsidian | Level 7

Figured it out.  Thanks...

ballardw
Super User

Please share your solution so that anyone that finds this thead from a search has a solution to go with the problem.

 

data_null__
Jade | Level 19

Using Formatted Input with a delimited file is not compatable and will not give correct result.

 

input Ref_Date $7. GEO $12. 'Geographical Classification'n $2. SIZE Description Vector Coordinate Value;

Remove those INFORMAT specifications from the INPUT statement.  

 

Delimited files use LIST input.

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