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

Hi SAS users,

 

I have a data set (csv file) including several variables. The values of the variables include a (') at the begining like below . Could you please advise how to use INFORMAT, and not to read the (') and just the numbers/characters ?

 

'WV99

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
mohamed_zaki
Barite | Level 11

You can us COMPRESS function to get rid of all single quotation in your variables. Or you can use SUBSTR if your variable contains other desired single quotation other than the one in the beginning.

For example

data test;
input x $;
x=compress(x,"'");
cards;
're34
'466
'terew
;
run;

 

View solution in original post

5 REPLIES 5
PGStats
Opal | Level 21

Share with us the code you tried and a few lines of the csv file.

PG
almmotamedi
Obsidian | Level 7

Here is the code:

 

data ABC.Entire_database_second;

infile "/v_share/Xiaomin/SCOPES/sas_dataset/Oct-08-2015/ScopesCalculations_SecondaryConstruction_*" linesize = 300 firstobs = 2 DSD ;

 

 

Informat
C_ST $3.0
C_DSTRB_AREA $5.0
N_RSK $7.0

 

input
C_ST $
C_DSTRB_AREA $
N_RSK $

 

run;

 

and attached is the csv file. Thank you

mohamed_zaki
Barite | Level 11

You can us COMPRESS function to get rid of all single quotation in your variables. Or you can use SUBSTR if your variable contains other desired single quotation other than the one in the beginning.

For example

data test;
input x $;
x=compress(x,"'");
cards;
're34
'466
'terew
;
run;

 

almmotamedi
Obsidian | Level 7
Thank you
data_null__
Jade | Level 19

The $QUOTE informat will also do that.  An you can associate the INFORMAT with all character variables.

33         data test;
34            input x:$quote.;
35            put x=;
36            list;
37            cards;

x=re34
RULE:      ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0                     
38         're34
x=466
39         '466
x=terew
40         'terew

 

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
  • 5 replies
  • 1157 views
  • 4 likes
  • 4 in conversation