I am providing a sample excel where the category section is not coming in the output as there are spaces.
I tried the different functions but I think missing something. can someone please let me know how to get the output?
Thanks
Can you just import the .csv file with proc import?
But you didn't post a CSV file. You posted some XLSX file. Does that file you posted have anything to do with the CSV file you started with. Remember do NOT let Excel open a CSV file for you, it will make changes based on what it thinks the strings in the file mean. Look at the CSV file with a text editor (or just dump a few lines to your SAS log with a simple data _null_ step).
Still don't see a csv file.
Input 1d : $12.
Status : $2
Category : $25
;
run;
We'd definitely have to see your input file in order to help.
Just looking at your code, I don't see the INFILE statement. The INFILE affects the behavior of the INPUT, so that would be important for us to see. There are different ways to code this, but presumably it looks something like this:
INFILE My_File DSD DLM=',';
This may not be the problem because you're getting at least some input, but it helps if you show us all the related code.
Jim
Hello @Sultana
As I understand from the previous post, you are importing csv files. The last variable is a character variable and it has space in between. For this reason your are not able to see the last variable.
I have converted your excel to csv and it can be imported without any issue.
proc import datafile="/path_to_your_file/Sample_sas.csv" out=sample_sas replace;
run;
The output will be like this
In case you want to read csv data inline you can use the following code
data test;
length ID Status Category $ 25;
INFILE datalines DSD DLM=',' missover;
input ID $ Status $ Category $;
datalines;
123-45-678,Active,FDI - UNION
678-90-111,Terminated,FT - Full Time
;
run;
The output will be same as in the first case.
In this later case you need to specify the length of the categorical variables if they are longer than eight characters.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.