BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tinghlin
Fluorite | Level 6

the original excel data is as follows:

tinghlin_0-1602214736937.png

Is it Possible to use proc import or other methods to import this filw?

i want the imported data as follows:

tinghlin_0-1602215188737.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jimbarbour
Meteorite | Level 14

@tinghlin,

 

It takes a bit of coding, but you can definitely do that.  Here are the results, and below the results is the SAS code.

 

Jim

 

jimbarbour_0-1602220479094.png

 

LIBNAME	School01	XLSX	"&Path\SampleData\Vertical_Merged_Cells.xlsx";

DATA	Class_Data;
	DROP	_:;

	SET	School01.Class_Data;

	LENGTH	_Prior_Code			$5;

	RETAIN	_Prior_ID			0;
	RETAIN	_Prior_Year			0;
	RETAIN	_Prior_SMTR			0;
	RETAIN	_Prior_Code			' ';
	RETAIN	_Prior_NStudent		0;
	RETAIN	_Prior_Proportion	0;

	IF	MISSING(ID)					THEN
		ID				=	_Prior_ID;

	IF	MISSING(Year)				THEN
		Year			=	_Prior_Year;

	IF	MISSING(SMTR)				THEN
		SMTR			=	_Prior_SMTR;

	IF	MISSING(Code)				THEN
		Code			=	_Prior_Code;

	IF	MISSING(NStudent)			THEN
		NStudent		=	_Prior_NStudent;

	IF	MISSING(Proportion)			THEN
		Proportion		=	_Prior_Proportion;

	_Prior_ID			=	ID;
	_Prior_Year			=	Year;
	_Prior_SMTR			=	SMTR;
	_Prior_Code			=	Code;
	_Prior_NStudent		=	NStudent;
	_Prior_Proportion	=	Proportion;
RUN;

 

 

 

View solution in original post

1 REPLY 1
jimbarbour
Meteorite | Level 14

@tinghlin,

 

It takes a bit of coding, but you can definitely do that.  Here are the results, and below the results is the SAS code.

 

Jim

 

jimbarbour_0-1602220479094.png

 

LIBNAME	School01	XLSX	"&Path\SampleData\Vertical_Merged_Cells.xlsx";

DATA	Class_Data;
	DROP	_:;

	SET	School01.Class_Data;

	LENGTH	_Prior_Code			$5;

	RETAIN	_Prior_ID			0;
	RETAIN	_Prior_Year			0;
	RETAIN	_Prior_SMTR			0;
	RETAIN	_Prior_Code			' ';
	RETAIN	_Prior_NStudent		0;
	RETAIN	_Prior_Proportion	0;

	IF	MISSING(ID)					THEN
		ID				=	_Prior_ID;

	IF	MISSING(Year)				THEN
		Year			=	_Prior_Year;

	IF	MISSING(SMTR)				THEN
		SMTR			=	_Prior_SMTR;

	IF	MISSING(Code)				THEN
		Code			=	_Prior_Code;

	IF	MISSING(NStudent)			THEN
		NStudent		=	_Prior_NStudent;

	IF	MISSING(Proportion)			THEN
		Proportion		=	_Prior_Proportion;

	_Prior_ID			=	ID;
	_Prior_Year			=	Year;
	_Prior_SMTR			=	SMTR;
	_Prior_Code			=	Code;
	_Prior_NStudent		=	NStudent;
	_Prior_Proportion	=	Proportion;
RUN;

 

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 414 views
  • 1 like
  • 2 in conversation