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

Hello,

I try to use proc import to import charactor variables (length $80. ) including double dash (–) from Excel 97-2003 worksheet. I use SAS 9.2 version. The double dash becomes to !! after imported to SAS. Could you please help? Thanks in advance.

Ying

1 ACCEPTED SOLUTION

Accepted Solutions
Hima
Obsidian | Level 7

I re-ran the code with your data.

PROC IMPORT OUT= TEST
            DATAFILE= "C:\Documents and Settings\TEST.xls"
            DBMS=EXCEL REPLACE;
RUN;

PROC PRINT; RUN;

Output:

ObsHosp1Hosp2
1hospital name -- sample 1hospital name -- sample 2

Can you re-run by replacing xls to EXCEL in your code?

View solution in original post

12 REPLIES 12
art297
Opal | Level 21

Can you post a copy of a worksheet, and your import code, that exhibits that behavior?

yyangca
Calcite | Level 5

My SAS codes:

proc import datafile="Z:\project1\myfile.xls" out=hosp DBMS=xls replace:

run;

Samle data in Excel is like:

Hosp1Hosp2
hospital name – sample 1hospital name – sample 2


The data after read in SAS:

hospital name !! sample 1

hospital name !! sample 2

Thanks!

Hima
Obsidian | Level 7

My excel has the below data

Desc
This is a sample test -- data step test for sas forums

Code:
PROC IMPORT OUT= TEST
            DATAFILE= "C:\Documents and Settings\TEST.xls"
            DBMS=EXCEL REPLACE;
RUN;

PROC PRINT; RUN;

Output:

Obs    Desc

  1      This is a sample test -- data step test for sas forums

Log:

33   PROC IMPORT OUT= TEST
34               DATAFILE= "C:\Documents and Settings\TEST.xls"
35               DBMS=EXCEL REPLACE;
36   RUN;

NOTE: WORK.TEST data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
      real time           2.56 seconds
      cpu time            0.60 seconds


37
38   PROC PRINT; RUN;

NOTE: There were 1 observations read from the data set WORK.TEST.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

DMartin
Calcite | Level 5

So what is the problem? Your output matches your input.

Hima
Obsidian | Level 7

Question was posed by yyangca . I replied him with an answer. That's not me who posed the question Smiley Happy.

DMartin
Calcite | Level 5

Oops!! Sorry about that. Must remember to engage brain before putting fingers in gear. :smileyblush:

art297
Opal | Level 21

That wasn't the OP who posted the above test.  While the OP hasn't posted an example that shows the problem, my initial guess is that the "double dash" is actually an emdash character, and that the result of the import isn't !! but, rather, a box appearing character.

yyangca
Calcite | Level 5

Awesome. It works!! Thank you so much for your help.

art297
Opal | Level 21

yyangca: what worked?  And, if the problem is solved, you should mark the answer as being correct.

yyangca
Calcite | Level 5

Replace DBMS=xls with DBMS=EXCEL in my original proc import. That way data are read in with "–" displayed correctly. I just marked the anwser from HIMA as correct answer. Thank you!

art297
Opal | Level 21

To test whether it is an emdash, can you change it to a dash with the following command in a datastep?:

variable=translate(variable,"-","14"x,);

Hima
Obsidian | Level 7

I re-ran the code with your data.

PROC IMPORT OUT= TEST
            DATAFILE= "C:\Documents and Settings\TEST.xls"
            DBMS=EXCEL REPLACE;
RUN;

PROC PRINT; RUN;

Output:

ObsHosp1Hosp2
1hospital name -- sample 1hospital name -- sample 2

Can you re-run by replacing xls to EXCEL in your code?

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 12 replies
  • 2133 views
  • 0 likes
  • 4 in conversation