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
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;
Share with us the code you tried and a few lines of the csv file.
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
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;
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
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 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.
Ready to level-up your skills? Choose your own adventure.