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 2025: Register Now

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1566 views
  • 4 likes
  • 4 in conversation