02-22-2018 04:26 PM
i'm importing data from excel and one of the columns is formatted as shown below:
So when I read in using proc import the col_length in dataset is displayed as below:
How to read the col_length as just a text so I can see as below:
02-22-2018 08:03 PM
Have you tried using the guessing rows option?
Do you have non-numeric values in these columns?
In any case, you can transform the columns back to numeric:
VAR1N = input(VAR1, ?? 32.10);
02-22-2018 08:21 PM
I dont want to convert to numeric. I want them to be displayed as they are. But what happens is in excel the value are 8,$200, but after importing the sas dataset displays $8,$200.
02-23-2018 10:13 AM
02-22-2018 10:00 PM - edited 02-22-2018 10:10 PM
Sounds like you have a numeric column in Excel where some cells are using one display format and other cells are using a different display format. That can work in a spreadsheet since you can treat each cell as a totally independent object. But in a dataset one variable can have only one type and one display format.
So if you really want a variable that can have a value that displays as 8 for one observation and another value that displays as $200 on another then you need to make sure that the variable is a CHARACTER variable.
You can force SAS to import your column from Excel as a character variable by making at least one of the cells in the column be an actual actual character value. SAS will convert columns that have mixed numeric and character values into character variables in the SAS dataset. But I am not sure that SAS will then add the dollar signs to numeric cells that have display format that adds dollar signs. I think SAS will just convert the actual number that is stored in the cell into a string of digits. So you might need to transform your full column to contain character values.
Another way is to instead create another column in your Excel file that you can use to tell you which format you want to use to transform the value in the nuneric column. Then you could write some SAS code to use the PUTN() function to convert your numbers into the character strings that you want to see.