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

Dear All,

 

I am infant to SAS and this is my first post on SAS , 

Uploaded CSV file to one of my folder and also able to read the data from csv file .,But I would like to get all the columns of CSV file .Can any one help me how can I do it

 

data tableau;
 infile '/folders/myfolders/DataFiles/SuperstoreSales.csv' delimiter=',' firstobs=2 ;
  input RowID OrderID Order Date$ Profit$;
 run;
 
 proc print data=tableau;
 run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

Hi

 

Why not use Proc IMPORT, like so

 

proc import
  file="/folders/myfolders/DataFiles/SuperstoreSales.csv"
  out=tableau
  dbms=csv
  replace
;
run;

Bruno

View solution in original post

4 REPLIES 4
Shmuel
Garnet | Level 18

How many columns do you have in the csv file?

According to your INPUT statement you get at most 5 colums.

If there are more - assign names and informats to the other columns too.

BrunoMueller
SAS Super FREQ

Hi

 

Why not use Proc IMPORT, like so

 

proc import
  file="/folders/myfolders/DataFiles/SuperstoreSales.csv"
  out=tableau
  dbms=csv
  replace
;
run;

Bruno

siddiqalimd
Calcite | Level 5
Thanks for your perfect .Blaze answer
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Do bear in mind that with the simplicity of proc import, you do lose the fine grained control you had with the datastep.  For simple tasks proc import may work, but under the hood what it is doing is scanning the file and guessing what the best way to read data in.  It may/may not get this right (causing you further work), and it may not do the same thing if the data changes in any way.  Once you move from simple tasks I would really advise that you put a bit more effort into the import, write the datastep yourself (you can take the output from proc import which will be in the log and modify that to your needs), this way you know exactly how the data will import each time.  

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
  • 4 replies
  • 2937 views
  • 1 like
  • 4 in conversation