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

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