Dear all,
attached is a sample of my data (my real data has over 100,000 row). when I use sas ->file ->import data wizard, after importing successfully, variable cusip lose the leading zeros,
e.g., the first observation has a cusip =00036020, after import, it cusip =36020,
how could I fix this? (note: I have many observations, so I can't do it manually).
thanks for your time !
Lan
Another possibility would be to take the already-imported variable and convert the data after the fact:
data want;
set have;
cuspid_char = put(cuspid, z8.);
drop cuspid;
rename cuspid_char = cuspid;
run;
You have two basic choices, one is to leave cuspid as numeric and assign and appropriate format such as Z8.0 to display with leading zeroes. Or import the data as a string. When proc import runs it generates data step code that appears in the log that can be modified. Either use F4 to recall the code to the program editor or copy from the log. The INFORMAT and FORMAT for your cuspid are likely defaulting to a best32. format. Change those lines to be informat cuspid $8. , remove the $ that will appear after the variable in the INPUT statement, save and run the modified code.
thank you so much!!!!
Lan
Another possibility would be to take the already-imported variable and convert the data after the fact:
data want;
set have;
cuspid_char = put(cuspid, z8.);
drop cuspid;
rename cuspid_char = cuspid;
run;
thank you so much!
Lan
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.