BookmarkSubscribeRSS Feed
Sultana
Calcite | Level 5

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

9 REPLIES 9
Reeza
Super User
Please provide more information. Remember we can see only what you post. It's usually a good idea to start with what you have (your input), what you want (your output) and what you've tried so far.

I can see your output but not what you want or start with so right now, I have no idea what issue you're trying to solve.
Sultana
Calcite | Level 5
I have provided my input file only thing is I use the CSV file and want
this to be in SAS EG output. But when I put in

Input 1d : $12.
Status : $2
Category : $25
;
run;

So the category column is coming as empty no output.

I need the FDI - UNION and FT - Full Time to be reflected in the category
column.

Please suggest
tarheel13
Rhodochrosite | Level 12

Can you just import the .csv file with proc import? 

Tom
Super User Tom
Super User

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).

Sultana
Calcite | Level 5
Attaching a CSV file
tarheel13
Rhodochrosite | Level 12

Still don't see a csv file.

Reeza
Super User
Attachments via email are not supported, you need to add your attachment via the website.
jimbarbour
Meteorite | Level 14
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

Sajid01
Meteorite | Level 14

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

Sajid01_0-1623864928830.png

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 1188 views
  • 2 likes
  • 6 in conversation