HI,
I'm using the import wizard with SAS to import a MS Excel CSV file. The problem is that SAS imports the entire file as a header with no observations.
For example,
SAS shows a 10 variable dataset with 0 observations:
RSID FULLNAME Priv Date EMAIL Ugkdd10 Jason Thomas DBA 2008 jt@hotmail.com
I need SAS to show me a 5 variable dataset with 1 observation:
RSID, FULLNAME, Priv, Date, EMAIL
Ugkdd10 Jason Thomas DBA 2008 jt@hotmail.com
I couldn't find any documentation of how to do this. Maybe proc transpose with some other formula?
Do I need to modify the import statement or figure out a way to recreate the dataset with SAS code (i.e., SCAN, SUBSTR, etc)?
Any help is very much appreciated.
Don't ask the same question multiple times.
OK - thought the first post was in the wrong discussion board.
Thanks,
Here is one of the CSV files... I have several just like this. It is very short and for some reason SAS imports every last one as 5+ headers and 0 obs.
That sample file should work fine as it is using CRLF as end of line markers.
That's what I was hoping for...but unfortunately, SAS imports everything into the header row.
Although TERMSTR=CRLF , I still get everything into a header.
Is there a way I can use SUBSTR to extract certain variables/header into observations instead of headers?
Thanks for any help.
Just write your own data step to read the file. For five variables it is probably less typing that writing the proc import code.
Run something like this to see what is actually in the file.
This program will read 5 blocks of 100 bytes and show you what is in there. You can check if there are CR, '0D'x, or LF, '0A'x, or both between the lines. Also whether your delimiter is a comma or a tab, '09'x.
data _null_;
infile 'tester.csv' recfm=f lrecl=100 obs=5 ;
input;
list;
run;
Hi:
Thanks for posting. It reads fine with a DATA step INFILE/INPUT. This worked for me.
Cynthia
THANKS ALL,
Unfortunately these solutions didn't work for me, the solution that did work is posted below. @Cynthia_sas your solution allowed my variables to come in correctly, but I wasn't able to get the observations. Nevertheless, I wrote my own data step that is working.
there may be a more efficient way of coding - but this works just fine so far 🙂
data do_&appname;
set &folder;
RACFID = scan(f1,1,",");
'Full name'n = scan(f1,2,",");
Server = scan(f1,4,",");
KFA = scan(f1,5,",");
x=countw(kfa,"|");
do i = 1 to x;
x1=scan(kfa,i,"|");
Privilege = catx("-",scan(f1,3,","),scan(f1,4,","),x1);
drop i x;
output;
end;
run;
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!
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.
Ready to level-up your skills? Choose your own adventure.