Hi Team,
I have a csv file in which some columns( example column A) has $ value and column B has (0 value). How can i remove $ symbol for column A and convert the column B value to numeric(NA)
"Community Matters" is for things concerning the working of this community, so i moved your post to Base SAS programming.
Consider a better subject line, as I see nothing concerning R here.
Please post an example of your csv data (use the {i} icon for posting text that must not be reformatted), and what you expect as data in a SAS dataset. NA is not a valid numerical value, but you might want to set zeroes to missing values in SAS.
Edit: changed subject to the edited subject line of the original post.
Your post is unclear. Where does the R from the subject title come in?
To get rid of $ just do:
a=compress(a,"$");
For b, not sure what you mean, NA is not a numeric, nor could be a numeric. You can fool it by using a format:
proc format;
value temp
0="NA";
run;
And apply that to the number, however the number will still be 0 behind the scenes. Always a good idea to post test data and required output in your questions to illustrate problems, and post what code you have.
In the diagram Columns A,B,C, D has $ symbol for currency, i need to get rid of them. And some of the values are missing which are shown as blank, i need to replace those blank with NA not a numeric
Edit [KB]: adapted the subject line.
Read (or convert) with the DOLLARw.d informat:
data have;
infile cards truncover;
input inval $;
cards;
$17.00
$20.23
;
run;
data want;
set have;
outval = input(inval,dollar10.);
format outval dollar10.2;
run;
proc print data=want noobs;
run;
inval outval
$17.00 $17.00
.
$20.23 $20.23
You can see how the empty value results in a missing numeric SAS value, which is the correct way to handle this.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.